Are you sure the IP is for the guest OS. I had the same problem and it turned out that the IP I had been using all along, the 192.168.56.101 was actually the Windows interface IP and the host OS IP was 192.168.56.103.
You can verify by doing ipconfig / ifconfig on both.
NOTE: I had also setup a static IP which it turns out I didn't need at all. In case you try from the start I found this tutorial to be better.
You can do it easily, without any expense.
1) At home, get a (free) dns from no-ip.com. You will be given a name like
my_name.no-ip.biz
2) Set it up, either on your router or on your pc; this way, even if your ISP changes your IP address, the moniker above always points to your home. The site no-ip.com has instructions on how to do this.
3) in your router, forward ports 6521 and a port for ssh (2222?) to your pc.
4) At work: set up a reverse tunnel to the moniker above, at first with ssh, and just check it works;
5) now download autossh for your distro, a small wrapper which uses port 6521 (that's why!) to check that the connection is still active, and if it is not it kills the running instance of ssh and starts a new one.
Typically, I write an executable called auto with this content:
#!/bin/sh
/usr/lib/autossh/autossh -M 6521 -f -p 2222 -2 -N -R 8400:localhost:22 my_name@no-ip.biz -i /home/myname/.ssh/id_rsa
This sets up a passwordless ssh connection (see the use of the cryptographic key **id_rsa) without terminal (-N), in protocol 2 (-2), using port 6521 to check that the connection is still active, and redirecting to my home port 22 all that is sent to port 8400 at work.
I put this line
su myname -c /home/myname/bin/auto
to execute the executable file auto in /etc/rc.local automatically at boot, as myself instead of root. I can now connect to my work pc with the command:
ssh -Y myname_at_work@localhost -p 8400 -i /home/myname/.ssh/id_rsa_work
where I now have to use the passwordless key for work. I have found that this connection is always, always up. Truly satisfactory.
Best Answer
First of all, both machines should be on the same subnet (e.g., 192.168.1.x). As an initial test, try pinging the Linux machine from Windows (
ping -t <Linux IP>
) and you should get a response. If you don't get a response, you won't be able to use SSH, and need to reconfigure your network.Secondly, you need to install an SSH server on your Linux machine. Since you're using Ubuntu, follow this guide on how to install OpenSSH.
The SSH server will be set to be run in the background, and I recommend you turning the Linux firewall back on and opening the ports it's listening on (usually TCP port 22). You can do that with:
Once that is setup, and you can ping your Linux machine from Windows, you should be able to use Putty or any other Windows SSH client to connect to your Linux machine. Just input your Linux IP and port and you should be good to go.
Now, if you want to connect from outside your home network, you will probably need to configure port forwarding for your router. This greatly depends from manufacturer to manufacturer, but it basically involves mapping your WAN IP to your LAN IP for the SSH port. Google for
<router name and model> port forwarding
and you should get some results.Port forwarding is only half of the equation, though. Your home Internet connection probably doesn't have a static public IP, which changes anytime you power cycle your router or your ISP forces an IP change. To get around having to remember your new public IP address everytime it changes, you can setup a dynamic DNS service. Which means you can enter a domain name (e.g. ssh.myhost.com) instead of an IP.
There are many free dynamic DNS services, such as No-IP, FreeDNS, etc. You usually have to run their client on your Linux machine which will update their DNS records anytime your public IP changes. Most routers though have this feature built-in, so check your router's admin page.