I can ssh from my home linux to school by typing

ssh <school id>@<school>.ca

but what if I want to do it the other way around?

I am at school and I want to connect to my home computer. How do I do this?

Suppose my username on my home computer is bob. How do I proceed from here? using putty/terminal?

I tried doing:

ssh bob@<public ip of home network found using whatsmyip>

but this didn't work.

I am sure my home has internet connection.

  • 1
    You will likely need to forward port 22 from your home router to your linux terminal. – Jesse_b Jul 21 '17 at 14:44
  • @Jesse_b after doing a bit more reading I believe that may be the issue – K Split X Jul 21 '17 at 14:46
  • But am I connecting properly (proper syntax)? – K Split X Jul 21 '17 at 14:47
  • In addition to opening port 22, you need to install ssh daemon on your home PC so that the daemon can bind to that port and listen for your connection.. One caveat: I highly recommend using key-pairs for this so you dont become as vulnerable and also disable root login – ryekayo Jul 21 '17 at 14:47
  • Yes that is the correct syntax. Your linux machine likely already has openssh installed but you can check with ssh -V or sshd -V . – Jesse_b Jul 21 '17 at 14:49

When you connect to public_ip:port, you are actually connecting to the router but since (most likely) your host is behind the NAT created by the router itself, you need to forward the connection to internal_ip:port.

Typically you can do this from the router's web page under the port forwarding section.

Be aware that this allows anyone to connect from anywhere, so make sure you are using ssh keys to login and prevent bruteforce via tools like failtoban or ufw/iptables.

  • But even if I use public_ip:port, wont it still ask for password? I don't see the major issue? – K Split X Jul 21 '17 at 14:51
  • 1
    Yes but passwords are easier to bruteforce. Also you can use the same key to log into multiple servers. – Matteo Jul 21 '17 at 14:56
  • Matteo answered the question, but just to add: if you use a router like pfSense you can set it to only allow SSH traffic from a certain IP or a range of IP's, etc. I have mine setup like this so I can RDP into my home PC from work, but not from anywhere else (since opening port 3389 for RDP to the entire internet is very insecure). – SamAndrew81 Jul 21 '17 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.