skeema / knownhosts

Go SSH known_hosts wrapper with host key lookup
Apache License 2.0
32 stars 4 forks source link

If the `Zone ID` of IPv6 contains spaces, should we omit it? #3

Closed lonnywong closed 1 year ago

lonnywong commented 1 year ago

On Windows, WriteKnownHost may write out results like this:

[demo.local]:2222,[fe80::20c:29ff:fe18:e2b5%Ethernet 6]:2222 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAfFFhkEb

This will result in the following error:

knownhosts: C:\Users\xxx\.ssh\known_hosts:9: illegal base64 data at input byte 5

Since knownhosts split lines by spaces: https://github.com/golang/crypto/blob/3f0842a46434ea6f56bf6e684c2b83d90e9cff07/ssh/knownhosts/knownhosts.go#L170-L177

My tests on local IPv6: test case platform result
ssh fe80::20c:29ff:fe18:e2b5 Windows
ssh "fe80::20c:29ff:fe18:e2b5%Ethernet 6" Windows
ssh fe80::20c:29ff:fe18:e2b5 MacOS X
ssh fe80::20c:29ff:fe18:e2b5%en0 MacOS

Should we omit the Zone ID of IPv6 if it contains spaces \t and ?