Blog Home Portfolio

Published

- 4 min read

Remote Coding Simplified: How to Access Your PC Anywhere with serveo.net

img of Remote Coding Simplified: How to Access Your PC Anywhere with serveo.net

If you’ve ever wished you could remotely access your PC to code, sidestepping the need for remote desktop software that often turns out to be either glitchy or pricey, then this article is tailored for you.

Let me share a bit of the backstory behind my motivation…

The crux of the matter is, I have a personal computer in my lab that’s always on. It’s equipped with a power-intensive GPU essential for my research endeavors. Yet, I’m also frequently on the move. Initially, my go-to solution was to physically transport my PC with me. But it dawned on me that flying with it wasn’t feasible without incurring steep baggage fees for shipping. Carrying a FULL ATX setup weighing between 35-60 LBS is no small feat. And YES, I did make an effort to lift it using my hips and legs, not my back, but let’s be real—I’m too old for this hassle at this point.

I explored various remote desktop applications, only to abandon them soon after. They lacked reliability, and the few dependable ones were beyond my budget, a common plight for a graduate student. My curiosity led me to wonder if I could simply SSH into my machine. However, this becomes impractical if you don’t opt for a static IP from your internet service provider or if configuring your router to accept incoming connections while you’re external to the network proves challenging.

That’s when I stumbled upon serveo.net, which essentially allows users to expose local servers to the internet via SSH. It acts as an intermediary, providing a public URL that forwards to your local server, simplifying remote access without the need for a static IP or complex router configurations.

The setup process is as easy as it gets.

  1. Check Prerequisites: Ensure you have SSH access on your local machine.
  2. Connect to Serveo: Use SSH to connect to serveo.net and establish a tunnel.
  3. Access Your Machine Remotely: Use the serveo.net URL to access your local server from anywhere.
  4. Automate: Automate the process of establishing a tunnel.

Step 1: Check Prerequisites

Before starting, make sure your local machine has SSH access enabled. This is crucial for creating the tunnel to Serveo.

Step 2: Connect to Serveo.net on Remote

Here, Remote is the computer that you want to remotely connect to. Open your terminal and use the SSH command to establish a tunnel to Serveo.

An important thing to note is that your server will be running only if the terminal with the following command remains open on your remote machine. Follow the last step if you want to automate this process which survives a reboot!

   ssh - R myalias: 22: localhost: 22 serveo.net
// myalias here is any unique name that you want to give to your PC. for example mylabpc.
// Port 22 is the port that is used for SSH communication in linux
// The -R option creates a reverse tunnel, mapping a port on the serveo.net side to a local port on your machine.

It should look something like this:

Step 3: Access Your Remote Machine from your Host

You know what, you are done. Now let us move to the Host, which is the computer that you are using to connect to your remote computer.

Run the folloing command on the host machine:

   ssh - J serveo.net user@mylabpc
// Here you just use the -J flag which tells ssh to use the jump server
// user here is your username on your remote machine, for example assume my username was "nvidia";
// So I would execute "ssh -J serveo.net nvidia@mylabpc"

You will then be prompted to enter your password upon which you should drop into your remote desktop’s shell.

It should look something like this:

Step 4: Automating establishing a tunnel on remote.

Make sure you have cron installed on your machine. Cron is essentially a job scheduler on Linux.

run the following command to open up a “crontab” which is essentially where you are going to write the commands that need to be scheduled.

   crontab - e

You will then be greeted with a window where you can enter the following so that it is scheduled on each reboot and it also checks every 5 minutes to make sure that the connection is still up and running, if not it reestablishes the connection.

   * /5 * * * * ssh -R myalias:22:localhost:22 serveo.net
// essentailly instructs linux to schedule the followinf command on reboot while checking to make sure there is an active tunnel every 5 minutes.

Step 5: Profit??!

That is all you need to be able to connect to your remote workstation from outside your network!

Until next time… Happy Computing!

Related Posts

Oops.. Waiting for the autor to whip up some cool related posts!