This is nice, but I also like the way fish (http://fishshell.com/) handles auto-completion:
When I type `ssh<tab>`, I get a list of hosts from my ~/.ssh/config plus hosts I have previously used.
I can actually use `ssh hn<tab>` and it gets auto-completed to `ssh hostname` because "hostname" is configured in my ssh config. The same works for `ssh user@<tab>`
fwiw, bash autocompletion does this automagically, too, but you might need to enable it. .ssh/config is definitely the canonical place to keep this stuff, but I like @haosdent's ranking concept. some of my boxes I rarely log into, and others I log into all the time.
this is fantastic work @haosdent - I'm working on adding automatic .ssh/config generation to Userify shortly. Could this read .ssh/config and build initial db for that?
Userify supports jump box creation[1] (automatic .ssh/config coming soon as well) and with bash autocompletion, you can hit any host in .ssh/config.
Is there any way to add ranking variables to .ssh/config that a regex or autocompletion script like this could read but plain SSH would ignore? 'bad configuration option' if I stick in an unrecognized variable name. Embed in comments?
It's amazing to me how many people use ssh and don't have an ssh config. It would be easier to maintain a .ssh folder in version control then to install this on each host and ssh until it learns.
Your auto provision of servers with chef or puppet should be adding them to you .ssh/config with a pointer to the ssh key and special requirements like tunnels through jump hosts/ bastion hosts.
Are there any resources you recommend on maintaining a .ssh folder? I've done a little reading, but I've never really needed to worry about working with multiple servers before, but I'm going to need to learn soon for a project at work.
There is actually a reason you can't have ~/.ssh/config symlinked the same way: ssh refuses to read a symlink for this file (for security purposes it is strict about the file type and permissions). My workaround is to copy the file instead of symlinking in my dotfile-setup script.
I version control the entire directory (ignoring the known_hosts file) somewhere like ~/config/ssh and symlink it to ~/.ssh. It contains a Makefile with a target that runs this command:
ln -s ${PWD} ~/.ssh
Just make sure the directory is chmod 700 and the important files in it are chmod 600.
Just my 2 cents, but I feel strongly that publicly released programs should be named with a minimum of 3 characters, reserving shorter names for user aliases and local commands.
26 comments
[ 2.6 ms ] story [ 60.3 ms ] thread[0] https://github.com/jpalardy/warp
https://github.com/rupa/z
SSH hosts tend to be long, so this seems like a good idea. I realize the .ssh/config exists, but this doesn't require setup per server.
Well you have to ssh to the serer a few times?
When I type `ssh<tab>`, I get a list of hosts from my ~/.ssh/config plus hosts I have previously used.
I can actually use `ssh hn<tab>` and it gets auto-completed to `ssh hostname` because "hostname" is configured in my ssh config. The same works for `ssh user@<tab>`
Is there any way to add ranking variables to .ssh/config that a regex or autocompletion script like this could read but plain SSH would ignore? 'bad configuration option' if I stick in an unrecognized variable name. Embed in comments?
1. https://userify.com/docs/tips/jumpbox/
Host xxx
Your auto provision of servers with chef or puppet should be adding them to you .ssh/config with a pointer to the ssh key and special requirements like tunnels through jump hosts/ bastion hosts.
I'm hoping someone chimes in with a bit of a better solution but there's no reason you couldn't have ~/.ssh/config symlinked in the same way.
Make sure you know which version/s of ssh you'll be dealing with and make the config work with the lowest version
Some HN articles/discussions:
https://news.ycombinator.com/item?id=4677049
https://news.ycombinator.com/item?id=7658459
Some stuff changed in OpenSSH 6+ so read the manpages, too.
Or am I missing the point?