Live data from Hacker News

BASH autocomplete for SSH

b.sricola.com

1–10 of 30 posts

Re: BASH autocomplete for SSH

#5
post #2

you can also use ctrl+R

I bind this to up-arrow in my .inputrc:

  "\e[A": history-search-backward
  "\e[B": history-search-forward
OP's method would be helpful when the line differs syntactically prior to the hostname e.g. different options, arguments, a pipe into it. Though that case is rare in my own usage.

Re: BASH autocomplete for SSH

#6
Two more places to extract hostnames for ssh auto completion are .ssh/known_hosts and the .ssh/config.

Or give zsh a try, simply autoload compinit and it will do ssh/sftp auto completions along with a boatload more out of the box.

Re: BASH autocomplete for SSH

#9
post #6

Two more places to extract hostnames for ssh auto completion are .ssh/known_hosts and the .ssh/config. Or give zsh a try, simply autoload compinit and it will do ssh/sftp auto completions along with a boatload more out of the box.

Ian MacDonald's bash completions (http://www.caliban.org/bash/) do this with known_hosts.

Re: BASH autocomplete for SSH

#10
post #6

Two more places to extract hostnames for ssh auto completion are .ssh/known_hosts and the .ssh/config. Or give zsh a try, simply autoload compinit and it will do ssh/sftp auto completions along with a boatload more out of the box.

I usually set up my SSH autocompletes to read from known_hosts. The problem is that on some systems, like say Debian, the hostnames are hashed for security reasons. So you have to add the following line to your .ssh/config to get the hostnames back into a readable form.

    HashKnownHosts no
Post reply on HN