openssh-portable icon indicating copy to clipboard operation
openssh-portable copied to clipboard

Fix Windows-generated fingerprint output

Open beldmit opened this issue 3 years ago • 5 comments

ssh-keygen -l mangles the output for the keys generated on Windows machine because of '\r' EOL. This patch fixes it.

beldmit avatar Mar 19 '21 11:03 beldmit

This should either be fixed downstream at Win32 within https://github.com/PowerShell/openssh-portable/tree/latestw_all/contrib/win32/win32compat or (since this file doesn't exist in that directory) this should be pushed upstream and verify Linux and BSD are unaffected by the change. Otherwise you'll need to add logic (through an ifdef windows) so that it only applies to Windows.

WSLUser avatar Apr 02 '21 13:04 WSLUser

Let me disagree. As the public key file is a text file, it's always a chance that it will be opened with a windows text editor, so non-Linux version should be ready to deal with '\r\n' EOLs.

beldmit avatar Apr 03 '21 09:04 beldmit

I should call out that plain old Notepad built into Windows has line ending support for Linux (thanks to WSL's existence). So users will always have a way (plus most good text editors support multiple platforms such as VS Code, which can read line endings from Mac, Linux, and Windows).

WSLUser avatar Apr 05 '21 19:04 WSLUser

Yesterday I reported the same issue here: mindrot#3385 (thanks @jakubjelinek for pointing out it's duplicate).

Let me copy my description here:

$ ./ssh-keygen -l -f test.pub 
3072 SHA256:Fh8V9v/JyBFlGI0ZqvWMb6480Ldm9dF0XJGTZFnoosI test@test (RSA)
$ unix2dos -q test.pub
$ ./ssh-keygen -l -f test.pub 
 (RSA)HA256:Fh8V9v/JyBFlGI0ZqvWMb6480Ldm9dF0XJGTZFnoosI test@test
$ read -r key < test.pub
$ printf '%s\r9999 SHA256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdea good@key\n' "$key" > bad.pub
$ ./ssh-keygen -l -f bad.pub 
9999 SHA256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdea good@key (RSA)
$ ./ssh-keygen -l -f bad.pub | less
3072 SHA256:rDIBjjZQEjZTzR3GIp/KERSlnMtsxeFrAbeye6TRoI0 test@test^M9999 SHA256:deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdea good@key (RSA)

glebfm avatar Feb 01 '22 08:02 glebfm

(thanks @jakubjelinek for pointing out it's duplicate). Sorry, I meant @Jakuje. :)

glebfm avatar Feb 01 '22 08:02 glebfm