-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Expand SSH hostname to IP where necessary (telnet for example) #2123
Comments
You should customize telnet completion instead. Repurposing a semi-public function hurts backward compatibility and people who use |
I use fzf also because there is no need to edit |
You may like to have a look at... You can then DIY your own hostname completion handler, using fzf via normal BASH TAB hostname completion. |
It seems as the proper way to DIY, but the referenced case is about using custom list (hostname source) and so at least partially-custom implementation is probably inevitable there. The case here would be to improve default completion capabilities so all host-autocompletion output would be cross-compatible between default-set command autocompletions. Another example besides |
TBH, I don’t quite understand this issue. Any valid host (be it a name or an address literal) should be usable with The only exception to this would be if one creates "fake" hostnames in
then SSH could work with I, personally, don't think that there's really a generic way in which One could perhaps offer something like what I propose in #3454 (comment), e.g. a Of course, one would then need different See also #3454 (comment) |
It's almost spot on. What you described actually already works with SSH commands since they handle the |
Hmm, I see. Though I wonder, whether this would be even desirable? I mean if someone makes up "fake" hostnames via SSH (which makes sense in some cases), then I still see why one wants to filter them out from non-SSH completions… but expanding such to some "real" name or IP feels conceptually a bit wrong, as the fake name is in principle something purely SSH internal. I'd also think it's difficult to do: Consider someone sets up a fake name in SSH (or anything similar) that is also a real domainname with IP. |
And, expanding all the way down to an IP address seems even more problematic, considering that hostnames may have attached several of them ( Again here, which of all these should the expansion use? One would loose e.g. round robin functionality and things like that, if simply one is chosen by chance. |
To be fair the fzf completions are configurable, this would just be another available option. Personally I'd find it very useful to be able to ping SSH hosts.
The name itself yes, in principle, but the function would expand it to a valid host address from
The fzf's function would be to expand known SSH hosts to a |
Still, as said above, what if the expanded name is a normal valid hostname? It might be in
And at the same time be in
which even makes sense, if some services are available via both IPs, but SSH only via one. At least if Another difficulty, I guess, might be if e.g. |
The normal valid hostname gets overridden due to the expansion, but that is user's problem. It'd be user's responsibility to know what they're doing (setup unique fake names). It's the same as with local DNS servers, hosts file configurations, ad blockers, ...
The primary purpose of the expansion would be to help users with numerous SSH hosts that know what they're doing (and keep their SSH host names unique). I'm not worried about users with messy There will always be a guy that will find it funny to name his router locally So a user has an option to set the
Only exact Picking the first |
Well I wouldn't consider this to be exactly the same situation. If I set up my own DNS server, but configure it in Don't get me wrong, I have nothing against the feature per se, I just think it may be quite tricky to implement properly and may cause behaviour that is not necessarily to be expected. One idea that I had (for another use case) might actually help with yours, too: What I'd like
Of course, there would need to be quite some additional functionality (e.g. a way to tell Anyway... this might be a nice way for what you want, just that the "pop-up" doesn't show usernames, but all possible mappings for the current hostname (which is possibly a fake hostname). |
I also did not want to have to deal with usernames. So if I type This wrapper expands the destination 'l' account using.
The wrapper handles normal ssh options, and if I actually give it a For more information look at my ssh notes.... that file also has sections on... I built this system a little at a time over 30 year! Starting back in the days of The 'r' script for example is NOT the only script that uses account names, so much of the 'lookups' was actually in other scripts that can be used by other scripts. For example I have a 'find_acct' script to do the username lookup, and 'find_host' script to do the DNS lookup using personal host aliases file and a list of domains the host might be in. But the scripts are optimized for my own use and the files I have created, and not something I would share. NOW... That is NOT to say I don't use However that does not mean you couldn't use 'fzf' to search against a verbose list of accounts and usernames you own, however you have them stored!
|
man fzf
)Info
Problem / Steps to reproduce
SSH hosts configuration file ~/.ssh/config is parsed when the fzf "host" completion is used. The configured names of hosts and their respective addresses (IP/domain) are parsed into two separate fuzzy completion hits. However, the configured names cannot be used with non-SSH commands as they do not use the SSH config file (telnet being an example) and so these fuzzy completion hits are not useful. It would be a practical feature if in these cases fzf expanded SSH names into addresses (after selecting the name from the list of hits).
Such a solution could be implemented with a new "host_sshexpand" completion mode, but if this is not desired, the existing "host" one could be refit for this purpose and provide the described expansion by default. And then the SSH-type commands (ssh, scp, dbclient, ...) could be treated as special cases where this additional expansion is not necessary.
The text was updated successfully, but these errors were encountered: