Sergei Zobov | Blog Software and robotics engineer

Accessible 3D-printer online with SSH port-forwarding

What is the problem?

Since I’ve bought a 3D-printer (Ender 3) I wanted to print remotely. I think you all know, that it takes quite long time to print something, so I want this machine to work even when I’m not at home.

I use an OctoPrint server and it has a very reach web-page to control the printer. Due to it’s the web-page I can make it available online for the remote control.

My ISP provides free static IPv4/6 address and I could use it, but I don’t want to deal with all this security configurations to prevent everyone from access to the printer. There is also one alternative, even suggested by official documentation – it’s VPN. And yes, it’s nice, but to be frank, I’ve already configured the OpenVPN instance, so I don’t feel it’s a simplest solution.

To add more context, the OctoPrint server run on small computer on Ubuntu 18.04. And I have a small virtual $5 server in Digital Ocean that also run on Ubuntu. That servers have both the SSH server and client out of the box, so why don’t I use it to provide and easiest and secure access to my printer?



The OctoPrint’s blog post shows that you can use different kinds of methods to access your printer and all of them have pros and cons. Like Polar Cloud, MakerBot Cloud or Ultimaker Cloud are all closed-source software, so you pay with your privacy and reliability, because it’s commercial companies with not so big audience, so they may not have an experience that covers all corner cases. Actually, thespaghettidetective looks like very nice solution, but it works on the private servers and costs some money. DiscordRemote or Telegram plugins are not the Octoprint interface and that’s not comfortable for me. VPN or Reverse Proxy are too complicated to set up. So I find SSH Port Forwarding is the most simplest and secure solution.


We have three main parts:

  1. The computer, constantly connected to the printer. With the operation system, that supports SSH Client. There are also two requirements: it should support 3d-printer controlling software, like OctoPrint or Repeater server. Likely, it will be Linux (Ubuntu/Debian) server, because they are normally used with computers like Raspberry PI, Orange PI, or even your old Android Phone.
  2. Virtual server, that could be ordered from the plethora of different kinds of cloud-providers, like Digital Ocean. With the operation system, that supports SSH Server. It could be either Windows or Linux.
  3. Your Linux/BSD/Windows/MacOS/Android computer, that also supports SSH client. I personally prefer to use Android mobile phone, with ConnectBot (google play, fdroid).

I assume, that you know, how to create and configure computer for 3d-printer server and virtual server. If you don’t, use this and this tutorials.

Everything I’ll describe below has been tested on Ubuntu 18.04, but I suppose you can find the same tutorials in the internet for any platforms and OS.

First of all, you need to connect to your cloud virtual server from 3d-printer’s computer and your own computer through the SSH. This tutorial from Digital Ocean will work pretty well for any other cloud providers, so I suggest you to use it.

Now, on computers, connected to 3d-printer and your computer, check connection to the cloud server by executing:

$ ssh <user>@<cloud_server_ip> -i <path/to/key_file> echo "connected"

If you see connected in console’s output everything is fine.

Then connect to the printer’s computer and execute:

$ sudo mkdir -p /usr/lib/systemd/system
& sudo vi /usr/lib/systemd/system/cloud-ssh-tunnel.service

Type i, copy the text below and Shift+Insert in terminal. After type Esc, :wq.

    Description=Tunnel to the cloud-server with port forwarding

    ExecStart=/usr/bin/ssh -R 8128: -N -T <user>@<cloud_server_ip> -i <path/to/key_file>


After execute in terminal:

$ sudo systemctl enable cloud-ssh-tunnel.service
$ sudo systemctl start cloud-ssh-tunnel.service

Actually, that’s all.

Now, all you need to connect to the printer’s computer and execute in terminal:

$ ssh -L 9999: -N -T <user>@<cloud_server_ip> -i <path/to/key_file>

Now in your browser you can open and you will see the OctoPrint page. Hooray!

That’s the screenshot from my Android phone using ConnectBot:


Of course, it will be much more easier for you, if you’re OK with Linux, but you still can read a little bit of manuals to learn how to deal with it.

Thanks and good luck!