ssh: connect to host myremotehost.com port 22: Connection refused
Just to share. (might be with different configuration)
In my case, I found that that error can happen because I have not install openssh-server
in the other machine.
After I install openssh-server in the other machine, the problem:
ssh: connect to host 192.168.XXX.XXX port 22: Connection refused
is solved.
First check
openssh-server
installed in that system.check the status of ssh service, make ssh service start.
sudo service ssh status sudo service ssh start
Check
iptables
in that system that port 22 is blocked. Just allow port iniptables
and then check.sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
Else change port number of
ssh
from 22 to 2222 by editingvi etc/ssh/sshd_config /etc/init.d/ssh restart.
Your ISP may block connections to port 22 (nothing you or your router can do about it). Just set SSHd to run on a different port, e.g. 2222.
In /etc/ssh/sshd_config
, change Port 22
to Port 2222
and then sudo service ssh restart
. Port forward 2222 (or whatever), and try again.