sshroute - automatically switch SSH connection params based on which network/VPN you're on
Posted by bilporti@reddit | linux | View on Reddit | 18 comments
Working from a few places and using multiple VPNs I was tired having 2-3 different commands to SSH into a single host, so I built a tool that automatically picks the right SSH connection params based on which network you're on (supports priority and thin wrapping ex. git):
https://github.com/thereisnotime/sshroute
Maybe it will help you too, drop a star if you like it (or a PR if you dont).
scriptiefiftie@reddit
at my workspace, i am often connected to wifi but there are times when i connect to Ethernet and see my ssh sessions break, and i have to connect again. does this solve that?
Jmc_da_boss@reddit
More LLM slop, this one isn't even hiding it. Plz make it stop
bilporti@reddit (OP)
This is the future, take it or leave it, AI will write most of the code soon. Why not show us your nice code?
Novel_Lie5519@reddit
the future is not slop of the day tools nobody asked for. you’ve just forgotten the delineation between “hacky tool i use for myself” and “helpful tool i built to share with the masses”
bilporti@reddit (OP)
You can ignore it if it's not useful to you
hippohoney@reddit
love small tools like this that solve real pain points. curious how it handles edge cases or conflicting priorities between multiple matching network conditions.
Novel_Lie5519@reddit
another day, another slop
FlorpCorp@reddit
I think tailscale is also a good solution here. If you're able to install the client on both ends, cause that's sometimes difficult in corporate environments. That way you always have a stable hostname (works for more than ssh), and you don't have to deal with ssh keys.
bilporti@reddit (OP)
True, but I dont like having VPNs always spending battery on my devices so I prefer jumphost vs local IP when in LAN thus the tool.
FlorpCorp@reddit
I think wireguard (what tailscale runs on) is very light on resources though.
donut4ever21@reddit
I use tailscale whenever I need to ssh into my server. I'll check this out and see. Thank you
mykesx@reddit
Shell aliases or functions.
akzever@reddit
Why would I need this over host pattern matching in the ssh config file?
bilporti@reddit (OP)
The SSH config is staic, you have to manually pick which alias to use ex. ssh webserver-vpn vs ssh webserver. sshroute detects which network you are on and uses the correct one
Damglador@reddit
Not completely static. I made a config that pings 3 addresses and picks the first that goes through
bilporti@reddit (OP)
Do you do SSH Match exec with a script to change the host?
Damglador@reddit
Yup, with
nc -zvw 1 192.168.1.<num> 22and other IP adressesbilporti@reddit (OP)
I used a similar approach before, but once you have more than a couple of hosts and networks it gets messy fast. Ended up building this to keep it all in one place.