PowerShell / Win32-OpenSSH

Win32 port of OpenSSH
7.32k stars 752 forks source link

ssh-keygen fails to convert pkcs8 public key to ssh #1400

Open v5pham opened 5 years ago

v5pham commented 5 years ago

Troubleshooting steps https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps None: ssh-keygen outputs nothing (for error or output).

Terminal issue? please go through wiki https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

Please answer the following

"OpenSSH for Windows" version ((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion) 7.9.0.0

Server OperatingSystem ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)

Client OperatingSystem Windows 10 Pro

What is failing ssh-keygen fails to return any output when attempting to convert a PKCS8 format public key to the ssh format using the following command:

ssh-keygen -i -m pkcs8 -f test_user.pub

(Assume test_user.pub is a properly encoded text file with the following content: -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvbGb+89PZgb8wzJe/WQ0 8igeoFPyEfxPeDV1T3JPPpolMWPaW92JGzOgcpQ7YgvWtLVS6HEC5/oWhaMrUljS Nh5DAkPgNvt7RoEDJWGbdHMD69W5Ab8omq8+RqpXBaqEfLGo+QII/s3mRcG3lBXM +3dw8ns4M/vKa66lDlE1moD6yzDnjz5PhgB72LyfqaTJR4KAb2mS5LDuN5PgUP+X gXCxgAX0sbuV3lpH72bQ92cIZEnLbfdtnsMhkCnhkrb2P6uZ9hjyNRovdpppMBwe U4+n1BYHNAiwTesE9O6VSIPhzjNqELxptXsXArnuJLBL4tMnmrDX38LnvQqWMnR/ NQIDAQAB -----END PUBLIC KEY----- )

Expected output On Linux, mac and the Git for Windows, the above command for the given test_user.pub, returns the following: $ ssh-keygen -i -m pkcs8 -f test_user.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9sZv7z09mBvzDMl79ZDTyKB6gU/IR/E94NXVPck8+miUxY9pb3YkbM6BylDtiC9a0tVLocQLn+haFoytSWNI2HkMCQ+A2+3tGgQMlYZt0cwPr1bkBvyiarz5GqlcFqoR8saj5Agj+zeZFwbeUFcz7d3Dyezgz+8prrqUOUTWagPrLMOePPk+GAHvYvJ+ppMlHgoBvaZLksO43k+BQ/5eBcLGABfSxu5XeWkfvZtD3ZwhkSctt922ewyGQKeGStvY/q5n2GPI1Gi92mmkwHB5Tj6fUFgc0CLBN6wT07pVIg+HOM2oQvGm1excCue4ksEvi0yeasNffwue9CpYydH81

Actual output Using the Windows port, it returns nothing:

PS C:\> ssh-keygen -i -m pkcs8 -f .\test_user.pub PS C:\>

jgallucci32 commented 4 years ago

I can reproduce the issue and notice the following errors in Windows Event Viewer

Event 1000, Application Error

Faulting application name: ssh-keygen.exe, version: 7.7.2.1, time stamp: 0x5b60b79a
Faulting module name: libcrypto.dll, version: 2.6.5.1, time stamp: 0x5b6de5de
Exception code: 0xc0000409
Fault offset: 0x00000000000e5008
Faulting process id: 0x38a0
Faulting application start time: 0x01d680cb85bf9e1c
Faulting application path: C:\windows\System32\OpenSSH\ssh-keygen.exe
Faulting module path: C:\windows\SYSTEM32\libcrypto.dll
Report Id: 49e87e22-424b-4289-9cd6-94f4e36ce8a1
Faulting package full name: 
Faulting package-relative application ID: 
Rotario commented 3 years ago

I can reproduce it - this is really annoying b/c the linux version works perfectly

Dean-NC commented 2 years ago

I needed this too, but same thing...no output and error logged in Windows Application event log. Using version 8.9.1.0 and Win 10 21H2. Strangely, on Windows Server 2012 R2, instead of out-putting nothing, a popup window shows stating the app has crashed. Ssh-keygen from Git for Windows version 2.35.1.2 works perfectly.

GianniBYoung commented 1 month ago

Still seeing this issue? Any work arounds/ plans to fix?