Using ssh-argv0

I'm pretty lazy. I discovered a little ssh trick today that other lazy folks might find useful. However, it's the type of trick that is mostly worthless in comparison to a properly built .ssh/config file. In fact, the only real thing this particular trick has going for it is that it's really easy to implement and remember.

Intro ssh-argv0...

ssh-argv0 is a simple wrapper that runs ssh and appends the current program name (as well as any arguments). It's installed as a part of the openssh-client package. Using it is pretty straightforward. Just make a sim-link called the hostname of the server you frequently connect to. Be sure to point it towards ssh-argv0
sudo ln -sf /usr/bin/ssh-argv0 /usr/local/bin/boomer.riley
Now you can simply call the sim-link to connect. You've got tab completion and it saves you a whole 4 keystrokes!
boomer.riley echo 'Just saved some time connecting to $HOSTNAME'
mriley@boomer.riley's password:
Just saved some time connecting to boomer
Instead of passing the login_name argument, you can roll that into the sim-link you create as well.
sudo ln -sf /usr/bin/ssh-argv0 /usr/local/bin/totallynotroot@boomer.riley
totallynotroot@boomer.riley
totallynotroot@boomer.riley's password:
Maybe you've got a lot of machines and you'd like to programmatically create a bunch of these. You can do that...
for i in {1..50}; do sudo ln -sf /usr/bin/ssh-argv0 /usr/local/bin/host$i.riley; done
Matt, that's just crazy. What will I do with all the time I've saved with this trick?
Good question. You've probably wasted more time reading this post than you'll ever get back with this trick... mwahahaha.

~MJ

2 comments:

Jon Crain said...

Yeah, I would spend my time creating proper ssh keys so you don't need to enter that password. And Gabe recommended Gas Mask as a simple quick etc hosts editor which has been super handy. Though a combination of all of these and you could type like a couple characters to connect!

Matt Riley said...

But.... surely you're encrypting your ssh key, right? :-P

In reality I just use bash aliases for single-character connect commands.