this post was submitted on 30 Dec 2025
23 points (96.0% liked)

Linux

10863 readers
852 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS
 

Edit/Solved: Thank you for all the great input! Both on alternative solutions and on security implications. I'm going to make a draft on how I would setup the e-mail method as securely as possible as a programming/scripting exercise, but will IRL probably end up using either some reverse tunnel/shell variant.

Edit 2: or, as a hardware solution, install an extra NIC that I expose to the opennet - thus enabling remote port forwarding - while binding all my sensitive processes/traffic to my encrypted NIC.

I cannot ssh into my Linux box from outside of my LAN since I'm behind a VPN that doesn't support port forwarding. Is it possible to make my Linux box receive, interpret and execute commands through e-mail instead? I've tried looking for answers through DuckDuckGo's search engine, to no avail. If I may dream, I would like to setup an e-mail server with a systemd service or just run a script that continuously downloads the emails, prints their content to stdin and executes, perhaps through command substitution, whatever is in stdin.

you are viewing a single comment's thread
view the rest of the comments
[–] dgriffith@aussie.zone 3 points 2 days ago* (last edited 2 days ago) (2 children)

It can be a Cron job that runs every minute. Run a script that:

  • Checks for the existence of a file, if it exists, exit.
  • (Optional) ping your end, if it's up, continue, otherwise exit
  • Touches said file.
  • Runs SSH to try and connect to your end. If the connection is made everything halts here until the connection drops.
  • Cleans up said file.
  • Exits.
[–] 0t79JeIfK01RHyzo@lemmy.ml 1 points 1 day ago (1 children)

I just use autossh for it.

I run an ssh connection to a VPS I pay like $5, which forwards a port there. The screen in the following command isn't required, but I have it so I don't have to keep the terminal window open.

screen -d -m -S autossh.eastusa.keepalive autossh -M 33333 -R VPS_IP_HERE:5555:localhost:22 root@VPS_IP_HERE

Then from other computers, to connect back

ssh -L 5555:localhost:5555 root@VPS_IP_HERE
ssh root@localhost -p 5555

For remote computers connecting back, the first ssh connects to the VPS and forwards a port to the remote computer. Then the 2nd ssh connection uses the forwarded port to complete the ssh connection to the computer behind the IP that can't port forward.

[–] 0t79JeIfK01RHyzo@lemmy.ml 2 points 1 day ago (1 children)

After thinking about it for a moment, if you don't want to pay for a VPS, I think you can run a hidden service with Tor then just use the onion address to ssh back into the computer. I found this guide. I haven't done it, but it seems like it should work.

Thanks! I'll noodle it around a little. :)