How To Enable Ssh In Ubuntu

How To Articles

Enabling SSH (Secure Shell) on Ubuntu can be a helpful way to remotely access and manage your Ubuntu system. With SSH, you can securely connect to your Ubuntu machine from any other device with an SSH client, such as another computer or a mobile device. In this article, I will guide you through the process of enabling SSH on Ubuntu.

Step 1: Checking if SSH is installed

Before we begin, let’s make sure that SSH is already installed on your Ubuntu system. Open the terminal by pressing Ctrl+Alt+T on your keyboard and type the following command:

sudo apt list openssh-server

If SSH is already installed, you will see the package name and a line indicating that it is installed. If it is not installed, you can install it by running the following command:

sudo apt install openssh-server

Step 2: Configuring SSH

Once SSH is installed, we need to make some configurations to ensure it is enabled and running properly. Open the SSH configuration file using the following command:

sudo nano /etc/ssh/sshd_config

This command will open the SSH configuration file in the terminal using the Nano text editor. In this file, there are several options that you can modify to customize your SSH settings. For now, we will focus on the default settings.

Look for the following line:

#Port 22

Remove the ‘#’ symbol at the beginning of the line to uncomment it. This line specifies the port SSH will use for incoming connections. By default, SSH uses port 22. If you want to use a different port, you can change the number after ‘Port’.

Next, look for the following line:

#PermitRootLogin prohibit-password

Again, remove the ‘#’ symbol at the beginning of the line to uncomment it. This line specifies whether the root user can log in using SSH. By default, it is set to ‘prohibit-password’, which means the root user cannot log in directly. If you want to allow root login, you can change it to ‘yes’.

After making the necessary changes, press Ctrl+X to exit Nano. When prompted to save the changes, press ‘Y’ and then ‘Enter’ to confirm the file name.

Step 3: Restarting SSH

Now that we have made the necessary configurations, we need to restart the SSH service for the changes to take effect. Run the following command to restart SSH:

sudo systemctl restart ssh

Step 4: Firewall Configuration

If you have a firewall enabled on your Ubuntu system, such as UFW (Uncomplicated Firewall), you need to allow SSH connections. Run the following command to allow SSH connections:

sudo ufw allow ssh

This command will allow incoming SSH connections through the firewall.

Step 5: Connecting to SSH

Now that SSH is enabled and running on your Ubuntu system, you can connect to it using an SSH client. Open your preferred SSH client on another device and enter the following command:

ssh username@your_ubuntu_ip_address

Replace ‘username’ with your actual username on the Ubuntu system and ‘your_ubuntu_ip_address’ with the IP address of your Ubuntu machine. If you are connecting from within the same network, you can use the internal IP address. If you are connecting from outside the network, you will need to use the external IP address of your Ubuntu machine.

When prompted, enter your Ubuntu user’s password to complete the SSH connection.

Conclusion

Enabling SSH on Ubuntu allows you to remotely access and manage your Ubuntu system securely. By following the steps outlined in this article, you can configure and enable SSH on your Ubuntu machine. Remember to always keep your SSH configuration secure by using strong passwords and configuring additional security measures if needed. Happy SSH-ing!