Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh-keygen.exe hangs for end user #836

Closed
hdatma opened this issue Aug 3, 2017 · 15 comments
Closed

ssh-keygen.exe hangs for end user #836

hdatma opened this issue Aug 3, 2017 · 15 comments

Comments

@hdatma
Copy link

hdatma commented Aug 3, 2017

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
Copy link
Author

hdatma commented Aug 3, 2017

Problem solved.

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

@manojampalam
Copy link
Contributor

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

@hdatma
Copy link
Author

hdatma commented Aug 4, 2017

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
Copy link
Collaborator

bagajjal commented Aug 4, 2017

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
Copy link
Collaborator

bagajjal commented Aug 8, 2017

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

@bagajjal bagajjal closed this as completed Aug 8, 2017
@borisbartlog
Copy link

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
Copy link

Andrew-Archon commented May 1, 2020

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
Copy link

1ycx commented Jul 15, 2020

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
Copy link

edyoung commented Nov 21, 2021

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
Copy link

grahamas commented Feb 4, 2022

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

@lukescharf
Copy link

lukescharf commented Feb 28, 2022

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
Copy link

ForNeVeR commented Jul 3, 2022

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

@malauhoff
Copy link

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
Copy link

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
Copy link

Same issue windows 10 powershell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests