PowerShell / Win32-OpenSSH

Win32 port of OpenSSH
7.25k stars 746 forks source link

ssh-keygen.exe hangs for end user #836

Closed hdatma closed 6 years ago

hdatma commented 6 years ago

Please answer the following

If it is a terminal issue then please go through wiki https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

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

latest

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

Windows 10 Pro

Client OperatingSystem

Windows 10 Pro

What is failing

ssh-keygen.exe -t ed25519 -o -a 100 -f ${HOME}/.ssh/id_ed25519

Expected output

success

Actual output

The command does not terminate. No output produced at all.

hdatma commented 6 years ago

Problem solved.

Since nobody chimed in, I guess you already know the solution, so I will not share it.

manojampalam commented 6 years ago

We haven't seen this problem yet. It helps the rest of us if you can share how you solved it.

hdatma commented 6 years ago

The command "ssh-keygen.exe -t ed25519 -o -a 100 -f ${HOME}/.ssh/id_ed25519" should interact with the user, asking for a password to protect the private key soon to be generated. In the case of Win32-OpenSSH, however, the interaction fails: the command does not terminate, and you must interrupt it manually. The trick to bypass the interaction is to provide the password directly in the command, as in "ssh-keygen.exe -t ed25519 -o -a 100 -f ${HOME}/.ssh/id_ed25519 -P your-password-here".

bagajjal commented 6 years ago

Not sure why the ssh-keygen hangs for you but it works on my machine (windows 10),

PS E:> .\ssh-keygen.exe -t ed25519 -o -a 100 -f e:\id_ed25519 Generating public/private ed25519 key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in e:\id_ed25519. Your public key has been saved in e:\id_ed25519.pub. The key fingerprint is: SHA256:Yr1hE36COC63SYnB2l83N8hHOQ5yrSUC1moHmR46TRs user@ip The key's randomart image is: +--[ED25519 256]--+ | | | + | | E . . | | . O + o . | | = O B S B | | o = B # . | |. + = . B = | | = + . + . | | + | +----[SHA256]-----+

bagajjal commented 6 years ago

Closing this thread as we couldn't reproduce on multiple machines..

borisbartlog commented 4 years ago

Having just encountered this issue myself (and resolved it), I believe the problem results when you try to run ssh-keygen in cygwin. It runs normally through cmd.exe, but hangs as described when run in the cygwin shell.

Andrew-Archon commented 4 years ago

I'm having this issue as well and for me it's specifically occurring when creating a new key by running ssh-keygen within a PowerShell script file using the PowerShell ISE without passing a passphrase parameter into the call.

Repro: Open PowerShell ISE and enter the following command into the editor: ssh-keygen -t rsa -C "test" -f rsa_id_TEST

Results in the script hanging with no output in the integrated PowerShell window.

1ycx commented 4 years ago

I'm using powershell 7.2 and can confirm this. It hangs on ssh-keygen -t rsa.

Edit: Closed powershell and tried on CMD. It works fine. Then tried on Powershell again. It worked. WHAT ?

edyoung commented 2 years ago

Just a quick note since I hit a related problem and found this issue.

ssh-keygen can prompt for input in several situations. As noted above you can hit this when it wants a password. In my case I hit a problem when the output file specified to -f already existed. In this case it prompts to check if you want to overwrite the file. This can cause a script to hang if there's no input for ssh-keygen to read. Because in the test environment sometimes the file was already there and sometimes it wasn't, this was a bit mystifying to debug.

grahamas commented 2 years ago

I just ran into the same problem in git bash. Same solution of pre-specifying both password and file name.

lukescharf commented 2 years ago

I just experienced this bug this morning with Windows 11 Pro.

ssh-keygen froze at the input-filename prompt under PowerShell (my default shell on Windows).

ssh-keygen succeeded under cmd.exe (not my default shell).

ForNeVeR commented 2 years ago

May it also depend on terminal? In my case, it always gets stuck in Windows Terminal, but works fine in the default conhost.

malauhoff commented 1 year ago

For me it stuck in Windows Terminal, but only if I added the -G parameter. I ended up in using the default filename and renaming later.

bshoshany commented 1 year ago

This happens to me too, on Windows 11 v10.0.22000.1098 with PowerShell 7.2.6. ssh-keygen works fine in Command Prompt, but gets stuck in PowerShell.

Ctucker9233 commented 1 year ago

Same issue windows 10 powershell