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: