I've set up port forwarding and allowed a firewall exception so I can ssh from my Linux Mint host into a Windows7/Cygwin guest.

#from linux host
hostuser@host$ ssh -p 2222 guestuser@localhost

What do I have to do to make it work in reverse as well?

#from cygwin guest (not working yet)
guestuser@guest$ ssh -p 2222 hostuser@localhost
  • Do you think this is a good question for superuser.com or would I stand a better chance of getting a good answer if I moved it elsewhere? – PSkocik Aug 18 '18 at 12:29
  • You should always elaborate on "not working yet". There is no reason why it shouldn't work, unless you have firewall rules that prevent it. – RalfFriedl Aug 18 '18 at 12:51
  • @RalfFriedl I set up port mapping in Virtual box, from Host/2222 to Guest/22 and from Guest/2222 to Host/22 and unblocked incoming 22 and outgoing 2222 in the Windows firewall, but only incoming host-to-guest connections work. Can't call out. – PSkocik Aug 18 '18 at 13:09
  • @RalfFriedl I get connection refused even if I turn the firewall off completely. It's not a firewall problem, I guess I just need to get Win7 to somehow forward to the the Host at TPC/22 if I connect to 2222 in WIn7. – PSkocik Aug 18 '18 at 13:13
  • Why do you try to connect to localhost instead of the host you want to connect to? – RalfFriedl Aug 18 '18 at 13:15

Virtualbox has multiple networking mode that you can choose for guest VMs. You did not specify what mode you chose, but if you chose 'NAT', (it's the default and most popular), you cannot ssh from the guest to the host. Because there is no route from the guest to the host.

Additionally, your guest OS does not know it is a VM. When you guestuser@guest$ ssh -p 2222 hostuser@localhost you are saying: ssh into localhost, the guest OS, port 2222, and connect to the sshd service running on the guest OS.

If you wish to have the guest OS be able to connect to the host OS you should change the VB networking mode. You will probably want 'Bridged' mode. Here the VM acts as a separate (physical) computer on your home network. It will receive a IP address via DHCP. Then you may ssh from one into the other, assuming there is no firewall rules or other 'barriers' between them. There is no port forwarding in this mode; all ssh connections will be through port 22 by default.


hostuser@host$ ssh guestuser@

guestuse@guest$ ssh hostuser@

Assuming host IP= and guest IP=

Opinion: Unless you are setting up a specific service on your guest, there is often little need for the guest OS to be able to connect its host in the way you are asking about. I would not go through the trouble of setting this up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.