How to configure SSH on Ubuntu VM with a Dynamic IP?

1

1

On a Windows 7 desktop, I've installed an Ubuntu virtual machine with VirtualBox.

On the virtual machine, I've installed OpenSSH and can connect to it from other 'real' machines on the network through its local 192.168.0.* address.

The question is, how can I set it up, so I can SSH into it over the internet?

My ISP gives me a dynamic address and I've set-up an account with No-IP.

user123404

Posted 2012-03-17T01:14:47.733

Reputation:

Answers

1

If you have your Windows machine behind a home router doing NAT, you can switch the virtual network card into bridged mode in the VirtualBox configuration. This will allow your VM to get an address from the router directly. You can then either set your router to give the VM a reserved address or set Ubuntu up inside the VM with a static address, and set your router to port-forward port 22 to the IP address the VM is using.

zigg

Posted 2012-03-17T01:14:47.733

Reputation: 362

1Some ISPs limit traffic on port 22. If this is the case for you, setup your router to listen on port "x" and forward it to ip_of_ubuntu:22" on the inside of your network. From there you just have to issue "ssh -p port_number username@domain_name.com" to log into Ubuntu from the outside – matrixx333 – 2012-03-17T01:57:28.863

Thanks guys, that worked. Sorry I can't upvote, I don't have enough 'reputation points' apprently! – None – 2012-03-19T09:36:19.157

0

The one thing that will probably save you more time and efforts than anything would be to use Hamachi from LogMeIn. It will create a zero config VPN. You install it in Ubuntu. Download Hamachi and install it, it will require the lsb package.

sudo apt-get install build-essential lsb

sudo dpkg -i <hamachi.deb file>

Install Hamachi on the other computer that you will be using to access Ubuntu.

Create a network either through Hamachi or LogMeIn's website interface. Join both computers to the newly created network. They will not have a direct tunnel to each other without having to open up any ports on your firewall. Even if your ISP gives you a new IP address, you will still be able to connect to the Ubuntu VM without any reconfigurations.

The other thing to do is to install LogMeIn on your desktop that is hosting the VM. This will allow you to remote into the computer and start the VM if it crashed or if you've forgotten to install it.

I use this setup every day and makes life so much easier.

kobaltz

Posted 2012-03-17T01:14:47.733

Reputation: 14 361