One minute
Fuzzy SSH
At work, I often have to SSH into multipe machines, but I hate having to remember the host names I’ve set in in my ~/.ssh/confg
file. I decided I would wrie a quick script to solve this problem for me.
The Code
#!/bin/sh
ssh $(cat ~/.ssh/config | grep "Host " | awk '{print $2}' | fzf)
This of course requires that you have FZF
installed and have a properly configured SSH config, but I find it saves me a lot of time with remembering host names and initiating the SSH connection.
I have improvements I’d like to make, like a few tweaks to have fzf
is displaying the list, but for the most part, this is how this has lived in my ~/.local/bin/
folder since I wrote it. Eventually I’ll integrate it with tmux to launch either a new window or a new session, I haven’t decided, but that’s for future me!
Sure, it’s stupid simple and I doubt I’m the first one to come up with it, but it sure has saved me the headache of having to remember the full hostname in my config, even with tab completion.
Until next time!