Search code examples
sshserverportremote-accesscentos7

Port 22: Connection Refused when you attempt to ssh in


On Centos 7 I am faced with the error below:

ssh -vvv ##.###.###.###
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ##.###.###.### [##.###.###.###] port 22.
debug1: connect to address ##.###.###.### port 22: Connection refused
ssh: connect to host ##.###.###.### port 22: Connection refused
pool-100-1-1-25:~ studiolaptop1$ ssh -vvv ##.###.###.###

Bizarrely, I have been getting this issue for awhile now when I try to ssh into my server. I have checked iptables looks all fine. Checked the ssh.config file, that is also looking fine, but clearly something is wrong. How can I solve this?


Solution

  • Switching from firewallD to iptables had caused this issue. Thus, needed to add relevant rules to the iptable to allow outbound and inbound connection on port 22.