Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a windows 7 machine and a linux machine. I want to SSH from windows to linux. How would I set this up if both are connected to my router at home? Would there be any changes necessary if I left my linux machine at home but took my windows machine with me to starbucks?

So far I've installed putty and disabled the firewall on both machines.

Ubuntu: sudo ufw disable

Windows: Simply disabled Windows firewall

Putty: Typed in the IP of my Ubuntu machine (both local and external IPs)

After I click connect, I get a connection refused message.

share|improve this question
1  
You're better off making a mesh hamachi network with both Win7 and Linux and then you won't have to worry about opening up any pinholes on the router. sudo apt-get install openssh-server on ubuntu and then use PuTTY to SSH from the Windows 7 to the Hamachi IP of the Ubuntu Server. –  kobaltz Feb 4 '12 at 23:11
    
Thanks, this worked well. I'm able to ssh from an external network now. Hamachi is convenient. I like not having to set up port forwarding and a dynamic DNS service. –  barrrista Feb 5 '12 at 1:17

2 Answers 2

up vote 2 down vote accepted

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:

sudo ufw allow ssh

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.

share|improve this answer
    
Thanks, not having to turn off the firewall is nice. –  barrrista Feb 5 '12 at 1:21

You need to set up port forwarding on your router. Once this is done, you will be able to use your public IP address with Putty and your router will recognize the traffic and direct it to your Ubuntu box. Make sure you have a strong password for SSH to prevent prying eyes.

Good Resource: http://portforward.com/ - will have router-specific directions for port forwarding.

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.