I am on a CentOS guest OS on a VirtualBox. I need to connect to this server through SSH using its public IP. More importantly, I need to connect to this server from within the guest host.

I have tried port forwarding with NAT as some forum suggested but I think I am lost there.

SSH output is just

root@localhost ~]# ssh [email protected]
ssh: connect to host xx.xxx.xxx.xxx port 22: Connection refused

I am able to connect to the server through host machine.

  • Is your VM (CentOS) has a private ip or public one? Dec 20, 2016 at 7:33
  • Is you hosting server run linux ? Dec 20, 2016 at 7:40
  • @WissamAl-Roujoulah The server I am trying to connect from my Centos guest OS has both public and private ip. The server I am trying to connect is Red Hat Enterprise 7 Dec 21, 2016 at 6:06
  • can you access the internet from your centos ? Dec 21, 2016 at 6:38
  • @WissamAl-Roujoulah yes Dec 21, 2016 at 6:42

1 Answer 1


Make sure to forward your ports on your target machine. (Ensure that port 22 is open in your router) After this you may need to ensure that your ssh service is running on your target machine. Run this: "service ssh start" without quotes; or you can run "service --status-all | grep ssh" to check if it is already running.

After these are taken care of, if you are wanting to ssh into a root account you may need to edit the ssh config file.


That link is for Kali but check step 4 where it says permit root login. Follow that step to enable ssh into root account.

Permit Root Login

Once these are setup you shouldn't have any issues using ssh.

You must log in to answer this question.

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