ssh autocomplete

complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
Add to your bash profile to minimize carpal tunnel syndrome. Doesn't work with [email protected] but appending "-l user" works fine if needed. Works for ping as well.. complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ping
Sample Output
$ssh myserver.<tab>

By: viner
2009-07-23 15:59:55

8 Alternatives + Submit Alt

What Others Think

Doesn't work very well on a modern SSH system where the known_hosts file is hashed. It's a good idea though.
ajt · 606 weeks and 1 day ago
@ajt to turn off hostname hashing, you may change either /etc/ssh/ssh_config or ~/.ssh/config and change HashKnownHosts from yes to no. . The approach shown here is cute, but there is a package in Debian/Ubuntu named 'bash-completion' which extends bash's command completion to help you tab-complete program *arguments*, like ssh hostnames or image/gimp file names when running gimp.
bwoodacre · 606 weeks and 1 day ago
@bwoodacre however the know_hosts file is hashed for a reason - to prevent "bad" scripts from hoping from server to server...
ajt · 606 weeks ago
@ajt I read your comment as you saying there was no way to turn off that hashing and so mentioned how to do it. Obviously there is a reason that hashing is turned on by default for added security, but it is still an option that may be turned off by the user if they so choose.
bwoodacre · 605 weeks and 4 days ago
Our prior goal is to surpass all the expectations of our client by providing outstanding customer support service, greater value and increased flexibility which in results optimize system functionality and improve operation efficiency. erp software company in india and erp for Construction and erp software providers and online erp software company and hospital management software in india and pathology software
delhis · 34 weeks ago
Our team is motivated and dedicated to providing you a seamless experience when it comes. csgo smurf
delhis · 34 weeks ago
We are best Professional SEO, Digital Marketing, Web Designing and Web Development Company. seo services company in bangalore and best digital marketing company in bangalore and web designing company in bangalore
delhis · 33 weeks and 1 day ago
Texas is the second largest state in the United States by area and population. While MaxRemind top rank medical billing company of USA offers it's Medical Billing Services in Texas , we also offer medical credentialing services in Texas. Our medical billing services are highly appreciated by Texas physicians because of high quality.
stevematt · 6 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: