Steady as a rock

…or so they say

 

Fun with OpenSSH

OpenSSH is an awesome implementation of the ssh protocol and I use it a lot. However, to connect to hosts at work I sometimes need to traverse many firewalls, using insane ssh configurations such as:

Host foo
ProxyCommand ssh -A host1 ssh -A host2 ssh -A host3 nc %h %p

Which means that connecting to host foo takes a lot of time. Using ControlMaster connections around helps, but then you have to remember to close the shell which is the ControlMaster last (~& helps though, but that’s cheating).

After perusing the ssh(1) and ssh_config(5) manpages (and parts of the OpenSSH source), I whipped up this simple python script that takes away this limitation and also leaves the ControlMaster connection around for future re-use. It also runs ssh-add for you if your agent has no key yet.

It saves me quite a bit of hassle on a daily basis so it could be useful for you as well if you depend on ssh a lot.

You’ll want this in your ~/.ssh/config to enjoy it most:

ForwardAgent yes

ControlMaster auto
ControlPath ~/.ssh/ssh_control_%h_%p_%r
Filed under : Personal, python
By Dennis Kaarsemaker
On June 9, 2007
At 20:21
Comments :
 

1 Comment for this post

 
daveg Says:

That pastebin link doesn’t seem to work anymore. Any change of you sending me a copy or uploading it elsewhere?

 

Leave a Reply