always open pi tunnels
August 22, 2023 | GeneralA helpful hit if you want to use Bludit for your own blog. TinyMCE is the default markdown plugin installed. If you activate EasyMCE without deactivating the former, then the save button breaks and you lose the content you were working on... Luckily this is a shorter post.
I have a raspberry pi on my office desk that is now serving as a nameplate using PyGame. Here's a link to the repo. But aside from that excitement, the way the office network is setup, I am unable to access wired devices from the corporate wifi network. Rather than go through the hassle to get this opened up, as it's not work critical and just a fun project, I'm going to tunnel into it.
This works using a program called autossh
. I'm sure this program has many purposes, but I'm just going to use it to keep a tunnel open to the pi for ssh.
On the pi, this is simply accomplished with the following command:
autossh -M 0 -f -N -R <tunnel_port>:localhost:22 <pi_user>@<mycloudserver.com> -i /path/to/ssh_key
As long as the users and keys are setup correctly, this will open a tunnel right up. If you have issues, substitute -f
for -v
to get some log output.
To make things even easier, I setup an ssh config profile on my server.
Host pi
HostName localhost
port <tunnel_port>
User <pi_user>
And that's all there is to it! Of course, there are security implications with this. If my server is compromised, my pi is compromised too. Soon enough I hope to mitigate this kind of risk by using a VPN on top of ssh keys to connect my devices. Then again, I might be able to install a vpn client on the pi that allows me to tunnel in without needing autossh. But that's an adventure for another day!
If you have any questions, comments, or insights, please feel free to reach out to me on Threads.