Stephen Connolly created SSHD-745:
-------------------------------------

             Summary: KnownHostEntry cannot parse [host]:port or IPv6 with 
%link entries
                 Key: SSHD-745
                 URL: https://issues.apache.org/jira/browse/SSHD-745
             Project: MINA SSHD
          Issue Type: Bug
    Affects Versions: 1.2.0
            Reporter: Stephen Connolly


My known hosts file contains lines like: (note I have sanitized the lines and 
switched entries to documentation reserved IP addresses and DNS names)

{code}
[host.example.com]:7999,[192.0.2.3]:7999 ssh-rsa AAAA...Z45M/
2001:db8:85a3::8a2e:370:7334%en1 ecdsa-sha2-nistp256 AAAAE2...q9zmk=
{code}

Both of which will bomb out with errors like:

{code}
WARNING: Failed (StreamCorruptedException) to reload server keys from 
/Users/stephenc/.ssh/known_hosts: Failed (IllegalArgumentException) to parse 
line #96 '2001:db8:85a3::8a2e:370:7334%en1 ecdsa-sha2-nistp256 
AAAAE2...q9zmk=': Invalid host pattern char in 2001:db8:85a3::8a2e:370:7334%en1
{code}

or

(This next one is a thrown away ssh server running in docker and the container 
is gone so I can provide the full unedited line)
{code}
WARNING: Failed (StreamCorruptedException) to reload server keys from 
/Users/stephenc/.ssh/known_hosts: Failed (IllegalArgumentException) to parse 
line #60 '[127.0.0.1]:49153 ssh-rsa 
AAAAB3NzaC1yc2EAAAADAQABAAABAQC5ntfSGAQOO2O/8ma7mtk9UaC6JWVlJ+6WAjnN3V510wc4nkkUcL66hZZyPLI0TYhk2CHNNQPeXkc6Cq7enSJab7SI06MhCQhF9yeuBQnphNBsUa01twPgycQOdrYey+4hIVXRF5BbckuU5nVAuFsPv7utNROmo+XoWoAdopSiejWs6Mrox+VIwgeN6peJ5l5jPqCjMEBTP9iNWgZMa+wQN7cTWpi7lIbK+a2hnzHz5P8oWFN8j8jREm+/6NK1IdW3c0CsLRWyee50GYYQOEi0zo1FfGweia5CbzfjRtfd0XFtUxGtULJpPoj9x/7xHuFUL1rYoKAGaTPzPdBHJTiJ':
 Invalid host pattern char in [127.0.0.1]:49153
{/code}

https://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files seems to 
indicate that {{[host]:port}} is the syntax for when the ssh server is using a 
non-standard port 

https://serverfault.com/a/771355/147023 reports that the % at the end of the 
IPv6 address is indicating the local link (in my case %en1 being WIFI on my 
macbook, but I have seem %eth0 on modern linux servers)

Completely blowing up for these entries seems rather wrong, I would expect 
either skipping such entries or actually being able to parse them.

Checking the current code on master it seems this issue has not been resolved 
yet:

IOW 
https://github.com/apache/mina-sshd/blob/5b0b163c5500fedc2a6bae0fc5e260d64fcf370a/sshd-core/src/main/java/org/apache/sshd/client/config/hosts/HostPatternsHolder.java#L289-L306
 still will reject a host name containing either the non-standard port 
specification or the link specifier



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to