Secure Shell Service known as SSH which is used for secure connection between a client computer and a server. Using SSH you can connect to your system remotely, perform administrative tasks and access files. In this tutorial you will learn how to enable SSH on Ubuntu to communicate securely with server.
Before you start with this tutorial, ensure that you’re logged in with non-root user account on your server with sudo privileges.
Install SSH On Ubuntu
By default in Ubuntu system, SSH server is not installed so you need to install it first. It can be easily install from Ubuntu repository by issuing following commands.
First of all you need to update apt package manager by typing:
sudo apt update
Now issue the below command to install SSH:
sudo apt install openssh-server
It will prompt you to enter password so just enter it and hit Enter key to continue with installation.
SSH service will be started automatically just after finished installation. You can verify installation by issuing below command:
sudo systemctl status ssh
It should show status as active as given below:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
Active: active (running) since Mon 2019-04-25 05:08:17 UTC; 45s ago
Main PID: 1001 (sshd)
Tasks: 1 (limit: 1152)
└─1001 /usr/sbin/sshd -D
q key to go back to terminal.
Finally, you installed the SSH on your Ubuntu system and you can connect it via SSH from any remote machine. Linux systems have by default installed SSH client and if you have need to connect it from Windows system you can use PuTTY SSH client.
Connecting to SSH Over LAN
You can connect your Ubuntu system over LAN using following command:
Change the username with your real Ubuntu user name and ip_address with your Ubuntu system ip address which you want to connect.
If you don’t know ip address of your system you can get it by running below command:
Now go back to remote machine from where you were trying to connect and run below command:
When you will connect it for first time, it will prompt you message like below:
The authenticity of host '192.168.43.125 (192.168.43.125)' can't be established.
ECDSA key fingerprint is SHA256:Rcbtm61VXuErBl7nE2+yowF7lgA2bLSiO/33/7qmRJP.
Are you sure you want to continue connecting (yes/no)?
yes and hit Enter key to continue. Next you will be prompted to enter password. Once you provide correct password then you will be logged in and show greeting message as below:
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-1035-aws x86_64)
Connecting to SSH Over Internet
For connect your Ubuntu machine over Internet you must know the public ip address of your machine.
Once you’ve found the IP address you can login by typing:
If you are exposing your machine to the internet you will need to configure the router to accept SSH traffic. Mostly, to configure your router to accept SSH traffic on a non-standard port and forward it to port 22 on the machine running the SSH service.
You can also secure your connection by setting up a SSH key-based authentication to your Ubuntu machine.
Manage SSH Service
For any reason you want to stop SSH service then you can do it by execute below command:
sudo systemctl stop ssh
To start it you can issue below command and can start it:
sudo systemctl start ssh
You can enable SSH service by running following command:
sudo systemctl enable ssh
Again, you can disable the SSH service by issuing below command:
sudo systemctl disable ssh
In this tutorial, you have learned how to install and Enable SSH service on Ubuntu 18.04 system. You can now login remotely to your server using any SSH client from Linux or Windows system.
If you have any question or suggestion you can leave a comment below.