Win32-OpenSSH icon indicating copy to clipboard operation
Win32-OpenSSH copied to clipboard

"Permission denied (publickey,password,keyboard-interactive)."

Open yooakim opened this issue 7 years ago • 22 comments

"OpenSSH for Windows" version 7.7.2.1

Server OperatingSystem Windows Server 2019 Datacenter

Client OperatingSystem Windows 10 Pro

What is failing

I can connect to the Windows Server 2019 (domain joined)

  • [ ] from Windows 10 client via Internet ssh -v username@ip DOES NOT WORK
  • [x] from Windows 10 using WinSCP.exe WORKS
  • [x] from Ubuntu WSL ssh jsw@fqdn WORKS
  • [x] locally in the server ssh username@localhost WORKS
  • [x] from Ubuntu ssh jsw@fqdn WORKS

Expected output Successful login

Actual output username@ip: Permission denied (publickey,password,keyboard-interactive).

The only client that fails is the ssh.exe from Windows 10. Can anyone help me find out why? Here's the ssh log:

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\yooak/.ssh/config
debug1: C:\\Users\\yooak/.ssh/config line 1: Applying options for *
debug1: Connecting to 40.118.103.34 [40.118.103.34] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\yooak/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\yooak/.ssh/id_ed25519 type 3
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_7.7
debug1: match: OpenSSH_for_Windows_7.7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 40.118.103.34:22 as 'june'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:yPNwoYDrXFsygNKZjuFjbOcpiV6UkXkq6KFeNCyJ7lg
debug1: Host '40.118.103.34' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\yooak/.ssh/known_hosts:38
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:S3gDtopWHfXlLhUNWCc89/x4eXOXIZVsNd3rgtyLHk4 C:\\Users\\yooak/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering public key: ED25519 SHA256:ZyLjH5uIMN14F/QkeOA2yFMM3J9CY87ytOybLQ2YbLw C:\\Users\\yooak/.ssh/id_ed25519
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: C:\\Users\\yooak/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\yooak/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\yooak/.ssh/id_xmss
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,password,keyboard-interactive).

yooakim avatar Mar 28 '19 17:03 yooakim

Please share server side logs. See https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps

Did you expect one of the public keys to work ? If you have give too many invalid key identities for the client to try (ex. you have a bunch of keys registered with ssh-agent that aren't valid for the target you are connecting to), you'll see that the server will reject the connection after 3 failed authentication attempts. This is by design

manojampalam avatar Mar 28 '19 18:03 manojampalam

Please share server side logs. See https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps

Did you expect one of the public keys to work ? If you have give too many invalid key identities for the client to try (ex. you have a bunch of keys registered with ssh-agent that aren't valid for the target you are connecting to), you'll see that the server will reject the connection after 3 failed authentication attempts. This is by design

I have two keys so the number of keys is likely not the issue. The strange thing, I think, is that it works fine from other SSH clients (WinSCP, ssh in WSL etc) but not the Windows ssh client.

yooakim avatar Mar 28 '19 18:03 yooakim

Same here! see this issue that I have been created. https://github.com/PowerShell/Win32-OpenSSH/issues/1369

agrawalsmart7 avatar Apr 18 '19 09:04 agrawalsmart7

I have a solution : the sshd_config :

#LoginGraceTime 2m #PermitRootLogin prohibit-password StrictModes no #MaxAuthTries 6 #MaxSessions 10

the StrictModes set the value no and uncoment the # finally you can ssh the windows server

Liuly-liuly avatar May 29 '19 07:05 Liuly-liuly

I have a solution : the sshd_config :

#LoginGraceTime 2m #PermitRootLogin prohibit-password StrictModes no #MaxAuthTries 6 #MaxSessions 10

the StrictModes set the value no and uncoment the # finally you can ssh the windows server

It's work for me. Thanks!

allmazz avatar May 23 '20 21:05 allmazz

Can you please share your client and server side logs? See manojampalam's comment above.

maertendMSFT avatar May 26 '20 21:05 maertendMSFT

From https://github.com/PowerShell/Win32-OpenSSH/wiki/Security-protection-of-various-files-in-Win32-OpenSSH#administrators_authorized_keys:

PS C:\>icacls administrators_authorized_keys /inheritance:r
PS C:\>icacls administrators_authorized_keys /grant SYSTEM:`(F`)
PS C:\>icacls administrators_authorized_keys /grant BUILTIN\Administrators:`(F`)

KiruyaMomochi avatar Jun 07 '20 19:06 KiruyaMomochi

Closing this issue as it's expected for admin users to store the public keys in $env:programdata\ss\administrators_authorized_keys file. This file should have right permissions.

bagajjal avatar Jun 08 '20 17:06 bagajjal

What are the right permissions for this file?

emhacker avatar Dec 27 '20 14:12 emhacker

What are the right permissions for this file?

https://github.com/PowerShell/Win32-OpenSSH/wiki/Security-protection-of-various-files-in-Win32-OpenSSH#administrators_authorized_keys

and https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement on using the Powershell utility to achieve the same.

arebee avatar Dec 28 '20 20:12 arebee

I have a solution : the sshd_config :

#LoginGraceTime 2m #PermitRootLogin prohibit-password StrictModes no #MaxAuthTries 6 #MaxSessions 10

the StrictModes set the value no and uncoment the # finally you can ssh the windows server

大佬!!!牛逼!!!

bladetin avatar Dec 26 '21 12:12 bladetin

时间过期不接受。

Liuly-liuly avatar Dec 26 '21 12:12 Liuly-liuly

Still facing same issue, none of the guides helped me.

orihomie avatar Feb 09 '22 06:02 orihomie

@orihomie - Please create a new issue. You get permission denied in so many ways. Don't forget to attach the ssh client logs (ssh -vvv user@ip) and the ssh server logs

bagajjal avatar Feb 09 '22 17:02 bagajjal

I have a solution : the sshd_config :

#LoginGraceTime 2m #PermitRootLogin prohibit-password StrictModes no #MaxAuthTries 6 #MaxSessions 10

the StrictModes set the value no and uncoment the # finally you can ssh the windows server

Thankyou! I love you ❤️😁

sntgchns avatar Aug 20 '22 18:08 sntgchns

时间过期不接受。

Liuly-liuly avatar Aug 20 '22 18:08 Liuly-liuly

"OpenSSH for Windows" version 7.7.2.1

Server OperatingSystem Windows Server 2019 Datacenter

Client OperatingSystem Windows 10 Pro

What is failing

I can connect to the Windows Server 2019 (domain joined)

  • [ ] from Windows 10 client via Internet ssh -v username@ip DOES NOT WORK
  • [x] from Windows 10 using WinSCP.exe WORKS
  • [x] from Ubuntu WSL ssh jsw@fqdn WORKS
  • [x] locally in the server ssh username@localhost WORKS
  • [x] from Ubuntu ssh jsw@fqdn WORKS

Expected output Successful login

Actual output username@ip: Permission denied (publickey,password,keyboard-interactive).

The only client that fails is the ssh.exe from Windows 10. Can anyone help me find out why? Here's the ssh log:

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\yooak/.ssh/config
debug1: C:\\Users\\yooak/.ssh/config line 1: Applying options for *
debug1: Connecting to 40.118.103.34 [40.118.103.34] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\yooak/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\yooak/.ssh/id_ed25519 type 3
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\yooak/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_7.7
debug1: match: OpenSSH_for_Windows_7.7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 40.118.103.34:22 as 'june'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:yPNwoYDrXFsygNKZjuFjbOcpiV6UkXkq6KFeNCyJ7lg
debug1: Host '40.118.103.34' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\yooak/.ssh/known_hosts:38
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:S3gDtopWHfXlLhUNWCc89/x4eXOXIZVsNd3rgtyLHk4 C:\\Users\\yooak/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering public key: ED25519 SHA256:ZyLjH5uIMN14F/QkeOA2yFMM3J9CY87ytOybLQ2YbLw C:\\Users\\yooak/.ssh/id_ed25519
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: C:\\Users\\yooak/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\yooak/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\yooak/.ssh/id_xmss
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,password,keyboard-interactive).

Just comment these two lines, thank me later

file source: C:\ProgramData\ssh\sshd_config

#Match Group administrators
# AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

ankushbhagatofficial avatar Aug 03 '23 14:08 ankushbhagatofficial

时间过期不接受。

Liuly-liuly avatar Aug 03 '23 14:08 Liuly-liuly

Solved, I did the following : 1- Edited the sshd_config file as follows: PasswordAuthentication yes 2- Restarted the "OpenSSH SSH Server" Service

and it worked fine

ekramyelnaggar avatar Sep 11 '23 14:09 ekramyelnaggar

时间过期不接受。

Liuly-liuly avatar Sep 11 '23 14:09 Liuly-liuly