In this post we will learn how to enable SSH server on your Ubuntu.
What is SSH?
SSH (Secure Shell) is a network protocol which supports encryption. It is mainly used for a remote secure configuration and management. It is common to use SSH protocol for a remote Linux administration. If we want to connect to a remote device using SSH protocol, this device should have an active SSH server.
Install SSH server
Let’s install openssh-server which is the most popular implementation of SSH protocol for Linux distributions.
Open your terminal and run the following command:
$ sudo apt update
The previous command downloads the latest information from the repositories on the available packages.
Now let’s install the openssh-server application:
$ sudo apt install openssh-server
Once the server is installed it will start automatically. We can check its status:
$ sudo systemctl status ssh
You should see that the status of SSH service is active(running). Now you should be able to log into your server remotely using one of SSH clients.
Connect to SSH server from Linux
All Linux distributions come with built-in SSH clients, therefore you can connect to your server from your Linux terminal. The command is the following: sshusername@ipaddress.
username – username of the user on a remote machine. In my case it is orkhans
ipaddress – IP address of the remote SSH server. In my case it is 172.16.10.21
Before you can enter the password for the provided username, you have to accept the fingerprint of the remote SSH server. Once you accept the fingerprint and enter the valid password you will log into the server:
[root@localhost ~]# ssh firstname.lastname@example.org
The authenticity of host '172.16.10.21 (172.16.10.21)' can't be established.
RSA key fingerprint is 1c:30:30:11:2f:f9:3f:47:7a:34:34:48:99:f3:39:57.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.10.21' (RSA) to the list of known hosts.
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.15.0-43-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
312 packages can be updated.
3 updates are security updates.
Last login: Mon Jan 28 11:37:44 2019 from 192.168.11.101
Connect to SSH server from Windows
Windows operating system does not come with built-in SSH client, therefore you have to download an SSH client yourself. My favorite one is PUTTY which is lightweight and free.
Launch PUTTY. Make sure the Connection Type is set to SSH, and that the IP address of the destination is also correct. Click Open.
Accept the fingerprint of your server and then enter your credentials. Then you will get an access to your server like this:
Start/Stop SSH Server in Ubuntu
At some point in future you might want to stop your SSH server. You can do this with the following command:
$ sudo systemctl stop ssh
Now you can check its status and you will see that it’s been stopped:
To start the SSH server again, run the following command:
$ sudo systemctl start ssh
Enable/Disable SSH server in Ubuntu
If you want to disable SSH server and prevent it from starting on boot, you should run the following command:
$ sudo systemctl disable ssh
Now SSH server will not start on boot. If you want to re-enable it, you can easily do this:
orkhans@ubuntu1:~$ sudo systemctl enable ssh
Now you know how to install SSH server on your Ubuntu machine and connect to it remotely. Thank you for reading.