Updated April 15, 2023
Introduction to Kali Linux SSH
Kali Linux SSH is defined as a cryptographic protocol for networking that manages and operates network services over an unsecured network. Remote command line, login, executing command remotely, and the network service is secured with SSH. SSH is an acronym for Secure Shell. Here the secure part of the name is derived because the data transfer through SSH is encrypted, which makes sure that in case of intercept by a third party, the data will be scrambled and unreadable, and the other part “shell” is based on Unix shell as this is the interface which is used for entering by the user. In this article, we would go through the working features like enable and disable of SSH, and then go through examples to get an overall understanding!
How does SSH work in Kali Linux?
Now that we know that SSH provides a secure channel over the unsecured network, it is compulsory to know the architecture behind the process of providing a secure channel. It is the client-server architecture, i.e. an application structure that manages partition tasks and workloads between the server and the requestor (i.e. the client). The main usage is to access the Unix-like operating system, though it can also be used to access Microsoft Windows.
For SSH to work, public-key cryptography is used for authentication of the remote computer first, and then user authentication is done if required. In order to use SSH, there are numerous ways to fulfil the tasks, with the most popular being generating public-private key pairs to encrypt the network connection and then use the password authentication to log on. First, the user enters the command, which has 3 distinct parts:
ssh {user}@{host}
Using the above command, the system is instructed that a secure shell connection is opened, which is made sure that it is encrypted. {user} is the account that is to be accessed. For example, if someone wants to access the system as admin, the user wants to access it as a root user. On the other part, {host} is the computer address one would want to access. This address can be a domain name or even an IP address. Once the above command is entered and executed, one will be prompted to enter the password for the account (if required). Also, once you type the password, it may appear that nothing is getting typed, as nothing appears on the terminal, but it’s nothing like that; the characters you are typing are transmitted as you type. Once the correct password is entered, the user will be welcomed with a remote terminal window, and it is through this one that can perform all actions on the remote environment.
How to enable and disable SSH in Kali Linux?
Now we have understood how SSH works in Kali Linux; it is time for us to take the first baby steps of enabling SSH in Kali Linux. Once we understand how to enable SSH on Kali Linux, we will understand how we disable SSH in Kali Linux. But even before enabling or disabling SSH in Kali Linux, we would need to know how we can install the OpenSSH server. Kali Linux doesn’t come with SSH enabled, although SSH is the most preferred way of connecting to remote environments. The connection is via a secure channel over an insecure network, from a server to a client where the client is running the SSH server SSH client programs! Below are some steps for enabling SSH in Kali Linux.
1. Install OpenSSH Server
The first step to install ssh is to open a terminal window and install the same by executing the below commands (assuming OpenSSH-server is installed already):
sudo apt-get install ssh
2. SSH configuration for a run on persistently
At first, we would need to remove run levels for SSH by executing the command:
update-rc.d -f ssh remove
Post removing the run levels, we would now load the default SSH run level by executing:
update-rc.d -f ssh defaults
3. SSH default keys change
It is now time for us to change the default SSH keys and have a random generated one, and the reason we do this is because in case we keep default SSH keys, an attacker might guess or crack it, and sensitive information will now be at stake as the attacker might use man in the middle technique to exploit the system. The command to perform the action is
cd /etc/ssh/
mkdir insecure_original_default_kali_keys
mv ssh_host_* insecure_original_default_kali_keys/
dpkg-reconfigure openssh-server
4. We are now ready to start the service or, in other words, enable ssh on Kali Linux by executing the below command:
sudo service ssh start
5. There might be some instances where the system will throw an error mentioning denial of access; for the same one would need to open a file named sshd_config under folder /etc/ssh and find the line of argument of PermitRootLogin and mention argument as prohibit-password. If it still doesn’t work, put yes as the argument.
With this, we now know the process of enabling SSH on Kali Linux. Now the next step is to know how we can disable SSH. We should know disabling because when the SSH is no longer being used, we shouldn’t keep the server running as anyone can break into the machine, and sensitive information may be compromised.
To stop the SSH server, we would need to execute the below command:
sudo service ssh stop
In order to keep SSH running but disable root login for SSH, we can follow the same steps as mentioned in Point 5 of enabling steps and just use “no” as an argument to PermitRootLogin.
Examples
Here we will look at how we can SSH using:
Option 1: IP address
Syntax: ssh [email protected][Here we can replace AmKy by the username as you desire and 192.27.09.91 with the desired IP address of the server]
Option 2: Domain Name
Syntax: ssh AmKy@eduCBAprod [Here we can replace AmKy by the username as you desire and eduCBAprod with the desired domain name of the server]
Once the password is entered, one can easily access the remote environment through the secured connection of SSH.
Conclusion
In this article, we have tried to take you through the working of SSH and then a step by step process of enabling and disabling SSH in Kali Linux. With the above knowledge, readers can start experimenting on SSH and are encouraged to go beyond this article in case confident, but just keeping one picture in mind that SSH can be dangerous if not handled cautiously.
Recommended Articles
We hope that this EDUCBA information on “Kali Linux SSH” was beneficial to you. You can view EDUCBA’s recommended articles for more information.