What do I have to do to be able to access my local network over ssh with a dynamic IP address?

  • 1
    Make sure to secure it properly as well, an ssh server listening on port 22 on the open internet is going to get hammered pretty hard with unwelcome connection attempts. – Thomas Jul 13 '15 at 5:50
  • Yeah, I really created a very strong password. Also, I'll try to write a script that detects brute force attacks and watch it using cron (I don't know if it's the best way to do that, but that is an issue for another question). But in the end, I'm just controlling my raspberry over ssh and not my personal computer, so I believe that I'm safe so far. Thanks for the advice! – Rafael Muynarsk Jul 13 '15 at 6:00
  • 1
    Consider using something like fail2ban that will temporarily blacklist IP's that keep trying (and failing) to log in. Make sure only the user with a very strong password can be used to log in (i.e. don't allow root/root logins ;) ) – Thomas Jul 13 '15 at 6:04

Use a dynamic DNS service. This is basically a little script or daemon that calls into a dns server so it gets updated whenever the IP changes. There are a number of providers for this service. For home use or only a few addresses you can use a free service like duck dns. I've used them since dyndns kicked off all their free customers and haven't had any problems. This assumes that you have a server that is publicly available and it is listening on some port (22 by default) for ssh connections. If you don't have the server set up edit your question with the set up you have we we can add more steps.

  • I see, I'd use the duck dns to deal with the IP that changes. But what configurations do I need to change on my modem in order to make it accept the connection? I'd like to allow access just to one machine of my local network. – Rafael Muynarsk Jul 13 '15 at 3:21
  • @Ramuyko: Go to portforward.com and learn all about it. Port forwarding is way off topic for this site. (Unless you're using a plain just-a-modem (i.e. not a router) along with, say, an OpenBSD based router, and are asking how to configure its firewall rules for port forwarding. And that would be a different question, really.) – Warren Young Jul 13 '15 at 3:24
  • 1
    @Ramuyko: Your modem just does modulation & demodulation, it doesn't filter anything (unless it's a combination modem access point or the like). If you have a router you can set the forwarding up pretty easily. Port forwarding/translation will do just that, you basically install a rule that says any traffic that comes to me on port 22, send to xyz client on the lan using port 22 (or some other port). This type of question is probably better for superuser but i don't think it's as off topic as Warren does. Especially if the firewall/router is linux based. – user1794469 Jul 13 '15 at 3:55

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.