MACboyet
By:
MACboyet

ssh: connect to host 188.xxx port 22: Connection refused - root and sudo user

December 15, 2015 2.4k views
Configuration Management Security Ubuntu

Hi,

After editing sshd_config to enable remote login - I wasn't able to log into SSH again.
the bad thing was, I exited SSH so I can't log into SSH again.

here's the error
<^>OpenSSH6.9p1, LibreSSL 2.1.7
debug1: Reading configuration data /etc/ssh/ssh
config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to [myIP] port 22.
debug1: connect to address [myIP] port 22: Connection refused
ssh: connect to host [myIP] port 22: Connection refused<^>

Is there a solution to log in back to SSH? Should I log into console and then do anything?

Please help, thanks!

2 Answers

If your root user has a password set you can log in via the console in the control panel. From there you should be able to edit sshd_config to revert your changes and restart the ssh service with

service ssh restart

Then you should be able to make an ssh connection again.

Ok for those of you having problems like this - make sure the sshd_config file has no syntax errors. In my case, there was an additional(unwanted) space that I have to delete. Thanks!

Have another answer? Share your knowledge.