Monday, 8 July 2024

ssh: connect to host port 22: Connection refused

 I was not able to connect our test_server and was getting below error.

#ssh test_server

ssh: connect to host test_server port 22: Connection refused

But ILOM (test_server-ilo) was accessible.

1) As ILOM was accessible , so connected to the ILOM first.

#ssh test_server-ilo

Password:

->

2) Started the console by using below command.

-> start /HOST/console

Are you sure you want to start /HOST/console (y/n)? y

Serial console started. To stop, type ESC (

test_server login: root

Password:

#

#pwd

/root

#hostname

test_server

#

3) Found sshd service was not running on the server.

#ps -ef|grep sshd

(you get process like "/usr/sbin/sshd -D" , if sshd service running on your server)

in my case it was not running.

4) Started the sshd service.

#systemctl start sshd.service

Above action resolved the issue.

In some cases ,there may be other types of issue , like below :-

"ssh_keys" not present in /etc/group file.

#cat group|grep ssh

sshd:!:74:

So add "ssh_keys:x:102:" in the /etc/group like below and save the file.

Restart the sshd service.

#cat group|grep ssh

sshd:!:74:

ssh_keys:x:102:

#systemctl start sshd.service