zsh-users
 help / Atom feed
* tab completion for ssh using FQDN
@ 2019-07-17 19:41 TJ Luoma
  2019-07-17 20:35 ` Grant Taylor
  2019-07-18  5:16 ` Colin Baxter
  0 siblings, 2 replies; 3+ messages in thread
From: TJ Luoma @ 2019-07-17 19:41 UTC (permalink / raw)
  To: zsh-users

I have several hosts defined in ~/.ssh/config like so:

Host myhost
       HostName myhost.luo.ma
       User myuser
       Port 5555

Something changed, because now when I type "ssh my[tab]" I get "ssh
myhost.luo.ma" instead of "ssh myhost" which then fails because it
isn't using the port specified in ~/.ssh/config.

I _think_ it has to do with the ~/.ssh/known_hosts file, because if I
delete the entry from that file, tab completion seems to work as I
expect.

I've looked around for a solution, and it appears that if I add this line:

       HostKeyAlias myhost

then the short hostname gets uses for the known_hosts file, but I'm
not sure if that's a "good" solution or not.

Is there a way to tell zsh to only do tab-completion for ssh out of
~/.ssh/config and ignore ~/.ssh/known_hosts ?

Thanks!

--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: tab completion for ssh using FQDN
  2019-07-17 19:41 tab completion for ssh using FQDN TJ Luoma
@ 2019-07-17 20:35 ` Grant Taylor
  2019-07-18  5:16 ` Colin Baxter
  1 sibling, 0 replies; 3+ messages in thread
From: Grant Taylor @ 2019-07-17 20:35 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]

On 7/17/19 1:41 PM, TJ Luoma wrote:
> I have several hosts defined in ~/.ssh/config like so:
> 
> Host myhost
>         HostName myhost.luo.ma
>         User myuser
>         Port 5555
> 
> Something changed, because now when I type "ssh my[tab]" I get "ssh 
> myhost.luo.ma" instead of "ssh myhost" which then fails because it isn't 
> using the port specified in ~/.ssh/config.

Tweak your Host entry to include the FQDN, e.g.:

Host myhost.luo.ma myhost

I don't think the order matters.  I personally like to put the FQDN 
first and then aliases after.  (I pattern off of the hosts file.)

> I _think_ it has to do with the ~/.ssh/known_hosts file, because if I 
> delete the entry from that file, tab completion seems to work as I expect.
> 
> I've looked around for a solution, and it appears that if I add this line:
> 
>         HostKeyAlias myhost
> 
> then the short hostname gets uses for the known_hosts file, but I'm not 
> sure if that's a "good" solution or not.

I think that's functionally (part of) defining a new host by the 
alternate name and recognizing the alternate name's host key.

I'd suggest trying adding aliases to the Host entry, as described above.

I've done things like this:

Host FQDN alias project<#>-db customer<#>-db current-problem-child

The project<#>-db is nice so that I can easily ssh into a project's DB 
server without needing to mentally translate to the host name.  I can 
literally do the following:

ssh project815-db

> Is there a way to tell zsh to only do tab-completion for ssh out of 
> ~/.ssh/config and ignore ~/.ssh/known_hosts ?

I'm sure there is a way.  I don't know what it is.  I've not dealt with 
this issue in about 6 years.



-- 
Grant. . . .
unix || die


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4008 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: tab completion for ssh using FQDN
  2019-07-17 19:41 tab completion for ssh using FQDN TJ Luoma
  2019-07-17 20:35 ` Grant Taylor
@ 2019-07-18  5:16 ` Colin Baxter
  1 sibling, 0 replies; 3+ messages in thread
From: Colin Baxter @ 2019-07-18  5:16 UTC (permalink / raw)
  To: TJ Luoma; +Cc: zsh-users

Hello TJ,
>>>>> TJ Luoma <luomat@gmail.com> writes:

    > I have several hosts defined in ~/.ssh/config like so: Host myhost
    > HostName myhost.luo.ma User myuser Port 5555

    > Something changed, because now when I type "ssh my[tab]" I get
    > "ssh myhost.luo.ma" instead of "ssh myhost" which then fails
    > because it isn't using the port specified in ~/.ssh/config.

    > I _think_ it has to do with the ~/.ssh/known_hosts file, because
    > if I delete the entry from that file, tab completion seems to work
    > as I expect.

    > I've looked around for a solution, and it appears that if I add
    > this line:

    >        HostKeyAlias myhost

    > then the short hostname gets uses for the known_hosts file, but
    > I'm not sure if that's a "good" solution or not.

    > Is there a way to tell zsh to only do tab-completion for ssh out
    > of ~/.ssh/config and ignore ~/.ssh/known_hosts ?

I get satisfactory tab-completion by setting Host to a name but Hostname
to an IP address. Seems to work.

Best wishes,

-- 
Colin Baxter
www.Colin-Baxter.com
---------------------------------------------------------------------
GnuPG fingerprint: 68A8 799C 0230 16E7 BF68  2A27 BBFA 2492 91F5 41C8
---------------------------------------------------------------------
The sole cause of all human misery is the inability of people to sit
quietly in their rooms.  Blaise Pascal, 1670
---------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 19:41 tab completion for ssh using FQDN TJ Luoma
2019-07-17 20:35 ` Grant Taylor
2019-07-18  5:16 ` Colin Baxter

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox