Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I don't have much Linux or networking experience, but I'm trying to SSH into an Ubuntu virtual machine from outside of my home network. The Ubuntu virtual machine (running inside VirtualBox) is running a Debian desktop. I did some research and found I had to forward port 22 from the router to the virtual machine.

-I changed the network setting on the VM to bridge.

-I'm forwarding the port to the VM.

-I checked (http://www.yougetsignal.com/) to show the port as open.

But when I try to connect it is still not working.

ssh username@<public-ip-address>
-- connection refused

Is there anything I have to do inside the virtual machine to allow incoming connections? Or forward any port?

If there is anything I'm doing wrong, any help would be greatly appreciated!!

share|improve this question
2  
I'm slightly confused about what's running where, so if I'm off base, forgive me; but... For troubleshooting, you could temporarily install an ssh demon on your main system (Ubuntu?), and see if you can connect to it from outside. That would let you know if it's getting through the router. Then you might be able to troubleshoot (if needed) from the main system to the VM to make sure that part is working. –  Marty Fried May 3 '12 at 23:08

2 Answers 2

A few things to check.

  • Have you started the SSH server (sshd) on the Ubuntu Virtual Machine?
  • On the Ubuntu VM, have you disabled the firewall or at least opened the SSH port (port 22)?
  • What kind of networking do you have set up for the Ubuntu VM in VirtualBox? NAT/Bridge/Host Only? It should be Bridge.
  • On the router, are you forwarding port 22 to the IP address of the Ubuntu VM or the host running VirtualBox? Again, you should have the Ubuntu VM networking running in Bridged mode and you should be forwarding to the IP it is assigned.

Check these things and if one of them does not fix the problem, add more detail to your question.

share|improve this answer
    
Yes, the ssh server is working on the vm because I can connect to it locally. About firewall I'm not sure how would I do that? Im using Bridge. Im forwarding the port to the VM since it has its own ip and its found on the router. –  user1354275 May 3 '12 at 20:42
    
From the Ubuntu VM, does "ssh localhost" work? How about "ssh <ip of Ubuntu VM>"? –  uther May 3 '12 at 21:31
    
yes i can ssh into the virtual machine from inside the network.. but not from the outside –  user1354275 May 4 '12 at 0:37

Take care that when you are inside your network and try to use the public IP address of your router, most routers are "clever" enough to figure that out and consider the request as coming from inside and not outside. Thus, the outside rule you created on your router is not applied and you are simply trying to connect to your router.

To verify this, you could try to redirect port 80 to your VM. Then try to connect with your browser to http:/// and you should get your router's configuration page.

If you are in this case and an external site tells you the port is open, you should be fine as it seems you did all the necessary steps. Try to connect to a free wifi (hot spot) and see if you can get to your VM, though I would b careful and check the SSH fingerprint carefully.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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