Read in 5 minutes
How to Enable SSH on Ubuntu 18.04
Secure Shell (SSH) is a cryptographic network protocol used for secure connection between a client and a server.
In this tutorial we’ll show you how to enable SSH on an Ubuntu Desktop machine. Enabling SSH will allow you to remotely connect to your Ubuntu machine and securely transfer files or perform administrative tasks.
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.
Enabling SSH on Ubuntu
SSH server is not installed by default in Ubuntu desktop systems but it can be easily installed from the main Ubuntu repositories.
To install and enable SSH on your Ubuntu system complete the following steps:
Open your terminal either by using the
Ctrl+Alt+Tkeyboard shortcut or by clicking on the terminal icon and install the
openssh-serverpackage by typing:
sudo apt update sudo apt install openssh-server
Enter the password when prompted and enter
Yto continue with the installation.
Once the installation is completed, the SSH service will start automatically. To verify that the installation was successful and SSH service is running type the following command which will print the SSH server status:
sudo systemctl status ssh
You should see something like
Active: active (running):
qto get back to the command line prompt.
Now that SSH is installed and running on your Ubuntu system you can connect to it via SSH from any remote machine. Linux and macOS systems have SSH clients installed by default. If you want to connect from a Windows machine then you can use an SSH client such as PuTTY.
Connecting to SSH Over LAN
To connect to your Ubuntu machine over LAN you only need to enter the following command:
ssh [email protected]_address
usernamewith the actual user name and
ip_addresswith the IP Address of the Ubuntu machine where you installed SSH.
If you don’t know your IP address you can easily find it using the
ip a command:
As you can see from the output, the system IP address is
Once you’ve found the IP address, go back to the remote machine you’re trying to log in with and enter the following command:
When you connect through SSH for the first time, you will see a message looking something like this:
The authenticity of host '192.168.121.111 (192.168.121.111)' can't be established. ECDSA key fingerprint is SHA256:Vybt22mVXuNuB5unE++yowF7lgA/9/2bLSiO3qmYWBY. Are you sure you want to continue connecting (yes/no)?
yes and you’ll be prompted to enter your password.
Warning: Permanently added '192.168.121.111' (ECDSA) to the list of known hosts. [email protected]'s password:
Once you enter the password you will be greeted with a message similar to the one below.
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-33-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage ...
You are now logged in to your Ubuntu machine.
Connecting to SSH Over Internet
To connect to your Ubuntu machine over Internet you will need to know your public IP Address and to configure your router to accept data on port 22 and send it to the Ubuntu machine where the SSH is running.
To determine the public IP address of the machine you’re trying to SSH to, simply visit the following URL:
When it comes to setting up port forwarding each router has a different way to setup port forwarding. You should consult your router documentation about how to set up port forwarding. In short, you need to enter the port number where requests will be made (Default SSH port is 22) and the private IP address you found earlier (using the
ip a command) of the machine where the SSH is running.
Once you’ve found the IP address, and configured your router you can login by typing:
ssh [email protected]_ip_address
If you are exposing your machine to the Internet it is good idea to implement some security measures. The most basic one is to configure your router to accept SSH traffic on a non-standard port and to forward it to port 22 on the machine running the SSH service.
You can also setup a SSH key-based authentication and connect to your Ubuntu machine without entering a password.
Disabling SSH on Ubuntu
If for some reason you want to disable SSH on your Ubuntu machine you can simply stop the SSH service by running:
sudo systemctl stop ssh
To start it again run:
sudo systemctl start ssh
To disable the SSH service to start during system boot run:
sudo systemctl disable ssh
To enable it again type:
sudo systemctl enable ssh
You have learned how to install and enable SSH on your Ubuntu 18.04. You can now login to your machine add perform common sysadmin tasks thought the command prompt. You may also want to setup a SSH key-based authentication and connect to your Linux servers without entering a password.
By default, SSH listens on port 22. Changing the default SSH port adds an extra layer of security to your server by reducing the risk of automated attacks.
If you are managing multiple systems, you can simplify your workflow by defining all of your connections in the SSH config file.
If you have any question, please leave a comment below.