Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh not completing from known_hosts #10

Closed
jarshwah opened this issue Mar 1, 2016 · 3 comments
Closed

ssh not completing from known_hosts #10

jarshwah opened this issue Mar 1, 2016 · 3 comments

Comments

@jarshwah
Copy link

jarshwah commented Mar 1, 2016

I've installed 2.1 from homebrew on osx, and for some reason the ssh completer for known hosts is not being run (or registered, I think). I was using an older version 1 that correctly completed via known hosts.

To confuse the matter, if I try to complete after sshfs <TAB>, that will successfully load from known_hosts. It seems that once known_hosts has been triggered, then regular ssh <TAB> will correctly list all known hosts.

The same behaviour occurs whether or not a hostname is partially written already, such as ssh dat<TAB> produces no output (unless another known_hosts completer has executed).

Bash version is 4.3.42:

$ bash -version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin14.5.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

I know this isn't much to go by, so if I can provide anything extra please let me know and I'll do so happily.

Here's an example from a new terminal session:

smeatonj ~/Development
$ complete -p | grep ssh
github.com' ssh
complete -F _known_hosts ssh-installkeys

smeatonj ~/Development
$ ssh <TAB>
private.com.au github.com

smeatonj ~/Development
$ complete -p | grep ssh
github.com' ssh
complete -F _known_hosts ssh-installkeys

smeatonj ~/Development
$ sshfs <TAB>
Display all 387 possibilities? (y or n)

smeatonj ~/Development
$ complete -p | grep ssh
complete -F _ssh ssh
complete -o nospace -F _sshfs sshfs
complete -F _known_hosts ssh-installkeys
complete -F _ssh autossh
complete -F _ssh slogin

smeatonj ~/Development
$ ssh <TAB>
Display all 387 possibilities? (y or n)
@scop
Copy link
Owner

scop commented Mar 1, 2016

sshfs completion needs ssh's completion and pulls it in on demand, that's why it starts to work after it. The complete -p output regarding ssh seems pretty broken to me. Please grab the whole section regarding ssh from the output (i.e. a few lines before what you already posted, or maybe the entire output somewhere), in this broken state. See also the troubleshooting instructions in README(.md) for info how to debug loading and execution of completions (set -x, etc).

@scop
Copy link
Owner

scop commented Mar 1, 2016

See also 06996ea

@jarshwah
Copy link
Author

jarshwah commented Mar 1, 2016

Thanks for your help, this has been driving me nuts for ages. Using set -x immediately spewed a tonne of output to the terminal. While trying to minimise the junk by commenting out stuff in my .bash_profile I came across this line:

[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" sc

After commenting that out everything began working correctly. Sorry for the noise, and thanks for putting me on the right track.

@jarshwah jarshwah closed this as completed Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants