ssh: connect to host localhost port 22: Connection refused in |Ubuntu | Error | Resolved

While installing Hadoop 2.6 on Ubuntu 16.04 got the error: ssh: connect to host localhost port 22: Connection refused. So here we provide resolution for this error in the terminal in Ubuntu 16.04 operating system.



SSH: connect to host localhost port 22: Connection refused

How to check ssh localhost is working or not, checking with below command:

ssh localhost

After entering the above command got like below error in terminal.
Error:

ssh: connect to host localhost port 22: Connection refused

Solution:
Here we need to install ssh in your ubuntu 16.04 using below command:

sudo apt-get install ssh

after that asked operating system password then will get installing ssh packages.

After completion of ssh check with below command whether it is installed or not.

sreekanth@sreekanth-Inspiron-5537:~$ ssh localhost
sreekanth@localhost's password:
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.15.0-70-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

133 packages can be updated.
0 updates are security updates.

New release '18.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Sun Dec 1 09:56:17 2019 from 127.0.0.1

Once ssh installation is completed on your Ubuntu 16.04 to achieve the “Passwordless SSH” to communication simply.




Summary: Sometimes we need to install SSH for Linux distributions like ubuntu, fedora for security purposes. In Windows operating system no need to install SSH because it is inbuilt for Windows os. While checking SSH getting like ssh: connect to host localhost port 22: Connection refused error so here we provide the solution with simple steps with pictures.