SSH to your machine from outside your home

Trying to SSH to your home computer is tougher than it sounds but it is actually easy. If this is the first time you are setting up SSH, then this post will be helpful. See, the Internet will return solutions to two different issues, both of which you need. Here is how to do it:

Your Router

If you want to get to your machine from outside your home network, you need to know your home network’s IP address – http://whatismyipaddress.com/. Then, you need to go into your router’s configuration page (usually 192.168.1.1) and forward port 22 to your designated computer. There are plenty of websites that can help you do this.  Once this is set up, you can test your connection from outside your home using http://www.yougetsignal.com/tools/open-ports/. If this is your first time though, you will likely need this second step.

Your SSH Server

Try to SSH to your computer from your own computer or from another computer in your network: ssh localhost

If you get a “port 22 connection refused error”, then it is likely not the router anymore. You probably do not have a SSH server running on your machine. If you have used Linux machines at work or school, then you are accustomed to having SSH running and ready to go but that is not how it is in the real world. Try some of the following commands to see if SSH is running and/or on your PC.

  • ps -C sshd
  • netstat -a |grep ssh
  • ls /etc/init.d/*ssh*

If nothing is getting returned, you need a server. You can install a good one called openssh-server from your Software Manager. You can also try adding it from the command line. The service should start and you can check with service ssh status. Since this is a service, you can also start | stop | restart the service if it dies.

False Positives

  • You will not need to SSH on port 2222.
  • You will not need to do NAT.

Sources:

  1. http://www.linuxquestions.org/questions/linux-networking-3/enable-ssh-329138/
  2. http://forums.fedoraforum.org/showthread.php?t=259571
  3. https://bbs.archlinux.org/viewtopic.php?id=168636
  4. http://portforward.com/
  5. http://whatismyipaddress.com/
  6. http://www.yougetsignal.com/tools/open-ports/
Advertisements
This entry was posted in How-To, Linux and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s