Friday, January 4, 2013

Bash Completion and ssh

The bash tab completions I use most are the ssh suite of completions, primarily hostname expansion. I also use other tab completions based off of the ssh suite, such as ping, telnet, etc. Hostname completion is primarily accomplished by reading the users ~/.ssh/known_hosts, but this is hampered by the current default configuration of the .ssh client, specifically hostnames are masked because the 'HashKnownHosts' option is set to yes. The default for 'HashKnownHosts' is set to yes to limit the usefulness of a compromised shell. A list of hosts that a particular use connects to can be utilized to exploit further machines that allow key based login or similar passwords. To change the default, edit ~/.ssh/config and add the following line:
HashKnownHosts no
This will not convert host entries to have plaintext hostnames, you may need to delete out entries and recreate them. To delete these individually, 'ssh-keygen' can be used:
ssh-keygen -f ~/.ssh/known_hosts -R <hostname>

No comments:

Post a Comment