I have been trying to set up a centos 7 server. There is no problem in accessing the server from the same network. But when I try

$ ssh -x user@ipAddressofServer

from an external network, It returns:

ssh: connect to host ipAddressofServer port 22: Connection refused

Can anyone help me with this?

  • we should allow 22 port from network firewall
    – Siva
    Feb 23, 2020 at 15:59
  • What is the communication path from the external network to the server? Is there a router involved? NAT (address translation)? Port forwarding? Is the IP address a public address or one of the unroutable ranges?
    – Kenster
    Feb 23, 2020 at 18:05

1 Answer 1


You should first make sure OpenSSH server is running and installed on the CentOS server. If it is up and you are trying to connect from outside of the network you might have to portforward the router. You should also make sure that the server has port 22 opened on the firewall by typing "sudo ufw allow 22"

  • How can I portforward the router?
    – physu
    Feb 25, 2020 at 9:07
  • Openssh-server is running and installed on CentOS server. I have portforwarded the router using DHCP.
    – physu
    Mar 10, 2020 at 16:19
  • I have not changed the default port. When accessing the server from the same network it works. But when I try to access from an external network , it says that connection has been refused.
    – physu
    Mar 10, 2020 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .