My desktop computer sits at my house. I, however, am usually roving around Ann Arbor with my laptop. I would love to be able to SSH into my desktop computer from my laptop computer wherever I go, but my ISP gives me a dynamic IP address, and I’m not inclined to keep track of its changes. Luckily, I figured out a way to ssh into my desktop while I roam around my city, even if my ISP decides to spuriously change my external IP address. Here’s how I did it.
- Sign up for a free account from dyndns.org.
This is a pretty cool service that assigns you a publicly accessible dns name and then makes sure it is bound to your dynamic IP address that you ISP gives you. My blind guess on how this works is that your router talks to the dyndns servers and constantly associates the DNS name they give you to what your router reports its external IP to be. Thats just a guess though. 😀 Once you sign up, and choose one of the DNS names they give to you, save all that info for step 2
- Configure your router
First of all, I have a D-Link router at my house, which has a built in configuration screen for dyndns services. I hope other brands of routers have similiar configuration options, but basically I just put in the information dyndns.org gave me into the router’s configuration screen, and saved it. I also forwarded the port I use for SSH to my desktop. I’m assuming you have many devices hooked up to your router, so find a way to forward your ssh port directly to the IP address that your desktop is using. I advise setting up a static IP address for your desktop when you’re doing this. Each router is different, so poke around until you have the port you use for SSH forwarded to your desktop.
- Configure your computer for SSH. This depends on what distro you’re using, but get sshd up and running. For Arch linux, running
sudo pacman -Sy openssh && /etc/rc.d/sshd start
will get you up and running with a default configuration. For Ubuntu systems, running
sudo apt-get install openssh-server && /etc/init.d/ssh start
should get you going. I advise changing the port number the SSH daemon looks for connections on by modifying the “Port” field in /etc/ssh/ssh_config. This number should match the port you forwarded in the previous step.
- Test it out!
ssh email@example.com -p $PORT_NUM
(replace username, example.homelinux.org, and $PORT_NUM appropriately, of course) If that works, then you can ssh into to your desktop computer wherever you happen to be in the world! Sweet.
I really like this service and hope you can find a way to use it to great effect. Remember, this setup is probably not feasible for setting up a real webserver, residential upload speed is usually pretty sucky. Its great though if you need to pull some howework you forgot on your desktop, or access your files while you’re on the go 😀