Skip to content

Cannot ssh to local account when using the sshd Service (as opposed cmd line sshd). generate_s4u_user_token: LsaLogonUser() failed. #1471

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

Closed
JimJingNeocis opened this issue Oct 1, 2019 · 8 comments

Comments

@JimJingNeocis
Copy link

JimJingNeocis commented Oct 1, 2019

Please answer the following

"OpenSSH for Windows" version
Win32 v8.0.0.0p1-Beta from github release

Server OperatingSystem
Windows 7 Professional

Client OperatingSystem
Windows 10 Home

What is failing
Unable to ssh to local user using public key when the service is running.

Expected output
Should be able to ssh in using public key authentication

Actual output
Similar to issue (#1213), I am not able to ssh with service running. I can use pub key using cmd line sshd.exe. But the difference is that I cannot ssh to local user either. My remote pc does not have internet access and is connected to my client pc using an Ethernet cable.

It looks like the direct reason of failure is

1344 2019-09-30 19:47:30.914 debug1: generate_s4u_user_token: LsaLogonUser() failed. User 'USERNAME' Status: 0xC000000D SubStatus 0.
1344 2019-09-30 19:47:30.915 debug1: generate_s4u_user_token: LsaLogonUser() failed. User 'USERNAME' Status: 0xC000000D SubStatus 0.
1344 2019-09-30 19:47:30.915 error: get_user_token - unable to generate token on 2nd attempt for user USERNAME

Log from sshd using sshd service

1344 2019-09-30 19:47:30.298 debug1: inetd sockets after dupping: 4, 4
1344 2019-09-30 19:47:30.298 Connection from 192.168.137.101 port 53327 on 192.168.137.209 port 22
1344 2019-09-30 19:47:30.298 debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.0
1344 2019-09-30 19:47:30.327 debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.0
1344 2019-09-30 19:47:30.327 debug1: match: OpenSSH_for_Windows_8.0 pat OpenSSH* compat 0x04000000
1344 2019-09-30 19:47:30.385 debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
1344 2019-09-30 19:47:30.385 debug1: SSH2_MSG_KEXINIT sent [preauth]
1344 2019-09-30 19:47:30.387 debug1: SSH2_MSG_KEXINIT received [preauth]
1344 2019-09-30 19:47:30.387 debug1: kex: algorithm: curve25519-sha256 [preauth]
1344 2019-09-30 19:47:30.387 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
1344 2019-09-30 19:47:30.387 debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none [preauth]
1344 2019-09-30 19:47:30.387 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none [preauth]
1344 2019-09-30 19:47:30.387 debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
1344 2019-09-30 19:47:30.592 debug1: rekey out after 134217728 blocks [preauth]
1344 2019-09-30 19:47:30.592 debug1: SSH2_MSG_NEWKEYS sent [preauth]
1344 2019-09-30 19:47:30.592 debug1: expecting SSH2_MSG_NEWKEYS [preauth]
1344 2019-09-30 19:47:30.624 debug1: SSH2_MSG_NEWKEYS received [preauth]
1344 2019-09-30 19:47:30.624 debug1: rekey in after 134217728 blocks [preauth]
1344 2019-09-30 19:47:30.624 debug1: KEX done [preauth]
1344 2019-09-30 19:47:30.826 debug1: userauth-request for user USERNAME service ssh-connection method none [preauth]
1344 2019-09-30 19:47:30.826 debug1: attempt 0 failures 0 [preauth]
1344 2019-09-30 19:47:30.826 debug1: user USERNAME matched 'User USERNAME' at line 90
1344 2019-09-30 19:47:30.851 debug1: userauth-request for user USERNAME service ssh-connection method publickey [preauth]
1344 2019-09-30 19:47:30.851 debug1: attempt 1 failures 0 [preauth]
1344 2019-09-30 19:47:30.851 debug1: userauth_pubkey: test pkalg rsa-sha2-512 pkblob RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM [preauth]
1344 2019-09-30 19:47:30.851 debug1: trying public key file C:\\Users\\USERNAME\\.ssh/authorized_keys
1344 2019-09-30 19:47:30.852 debug1: C:\\Users\\USERNAME\\.ssh/authorized_keys:1: matching key found: RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
1344 2019-09-30 19:47:30.852 debug1: C:\\Users\\USERNAME\\.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
1344 2019-09-30 19:47:30.852 Accepted key RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM found at C:\\Users\\USERNAME\\.ssh/authorized_keys:1
1344 2019-09-30 19:47:30.858 Postponed publickey for USERNAME from 192.168.137.101 port 53327 ssh2 [preauth]
1344 2019-09-30 19:47:30.906 debug1: userauth-request for user USERNAME service ssh-connection method publickey [preauth]
1344 2019-09-30 19:47:30.906 debug1: attempt 2 failures 0 [preauth]
1344 2019-09-30 19:47:30.906 debug1: trying public key file C:\\Users\\USERNAME\\.ssh/authorized_keys
1344 2019-09-30 19:47:30.907 debug1: C:\\Users\\USERNAME\\.ssh/authorized_keys:1: matching key found: RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
1344 2019-09-30 19:47:30.907 debug1: C:\\Users\\USERNAME\\.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
1344 2019-09-30 19:47:30.907 Accepted key RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM found at C:\\Users\\USERNAME\\.ssh/authorized_keys:1
1344 2019-09-30 19:47:30.909 debug1: auth_activate_options: setting new authentication options
1344 2019-09-30 19:47:30.909 Accepted publickey for USERNAME from 192.168.137.101 port 53327 ssh2: RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
1344 2019-09-30 19:47:30.909 debug1: monitor_child_preauth: USERNAME has been authenticated by privileged process
1344 2019-09-30 19:47:30.913 debug1: auth_activate_options: setting new authentication options [preauth]
1344 2019-09-30 19:47:30.913 debug1: monitor_read_log: child log fd closed
1344 2019-09-30 19:47:30.914 debug1: generate_s4u_user_token: LsaLogonUser() failed. User 'USERNAME' Status: 0xC000000D SubStatus 0.
1344 2019-09-30 19:47:30.915 debug1: generate_s4u_user_token: LsaLogonUser() failed. User 'USERNAME' Status: 0xC000000D SubStatus 0.
1344 2019-09-30 19:47:30.915 error: get_user_token - unable to generate token on 2nd attempt for user USERNAME
1344 2019-09-30 19:47:30.915 error: unable to get security token for user USERNAME
1344 2019-09-30 19:47:30.915 fatal: fork of unprivileged child failed
1344 2019-09-30 19:47:30.915 debug1: do_cleanup

Log from ssh client

PS C:\Users\myname\Downloads\OpenSSH-Win64\OpenSSH-Win64> ./ssh.exe [email protected] -vvv
OpenSSH_for_Windows_8.0p1, LibreSSL 2.6.5
debug3: Failed to open file:C:/Users/myname/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 192.168.137.209 is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.137.209 [192.168.137.209] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\myname/.ssh/id_rsa type 0
debug3: Failed to open file:C:/Users/myname/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_rsa-cert.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_rsa-cert type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_dsa error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_dsa.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_dsa type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_dsa-cert error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_dsa-cert.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_dsa-cert type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_ecdsa error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_ecdsa.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_ecdsa type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_ecdsa-cert error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_ecdsa-cert.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_ecdsa-cert type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_ed25519 error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_ed25519.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_ed25519 type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_ed25519-cert error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_ed25519-cert.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_ed25519-cert type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_xmss error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_xmss.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/myname/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/myname/.ssh/id_xmss-cert.pub error:2
debug1: identity file C:\\Users\\myname/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.0
debug1: match: OpenSSH_for_Windows_8.0 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 192.168.137.209:22 as 'USERNAME'
debug3: hostkeys_foreach: reading file "C:\\Users\\myname/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\myname/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 192.168.137.209
debug3: Failed to open file:C:/Users/myname/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],[email protected],ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
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
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:EumqmYnCznzYtuOqMQp8vAyr9cYYKWhwFsPiMNJPr78
debug3: hostkeys_foreach: reading file "C:\\Users\\myname/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\myname/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 192.168.137.209
debug3: Failed to open file:C:/Users/myname/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug1: Host '192.168.137.209' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\myname/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug3: unable to connect to pipe \\\\.\\pipe\\openssh-ssh-agent, error: 2
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\\Users\\myname/.ssh/id_rsa RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
debug1: Will attempt key: C:\\Users\\myname/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\myname/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\myname/.ssh/id_ed25519
debug1: Will attempt key: C:\\Users\\myname/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
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>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,keyboard-interactive
debug3: start over, passed a different list publickey,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\myname/.ssh/id_rsa RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: C:\\Users\\myname/.ssh/id_rsa RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
debug3: sign_and_send_pubkey: RSA SHA256:/8MzOEGLiJH6kpLBWo662/sWnuSBS9i2exthxLpBYOM
debug3: sign_and_send_pubkey: signing using rsa-sha2-512
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.137.209 ([192.168.137.209]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: couldn't find CreatePseudoConsole() in kernerlbase dll
debug3: This windows OS doesn't support conpty
debug1: console supports the ansi parsing
debug3: Successfully set console output code page from:65001 to 65001
debug3: Successfully set console input code page from:437 to 65001
debug3: WSARecv - WSARecv() ERROR: io:000001792AA37360 10054
debug3: recv - from CB ERROR:108, io:000001792AA37360
debug3: send packet: type 1
debug3: send - WSASend() ERROR:10054, io:000001792AA37360
client_loop: send disconnect: Connection reset
debug3: Successfully set console output code page from 65001 to 65001
debug3: Successfully set console input code page from 65001 to 437
@NoMoreFood
Copy link

You are correct on the errors of interest. Anything unique about your username or your environment that might be different from standard installation of Windows? The noted error is translates to STATUS_INVALID_PARAMETER.

@JimJingNeocis
Copy link
Author

I don't think so. My username is a four alphabet letters word. And the pc name is username-PC. Other than the PC is installed completely offline, there is nothing special that I can think of. Is there a way for me to get more information about which parameter is invalid and what its value is?

@currybullen
Copy link

currybullen commented Nov 17, 2019

I am facing this issue as well. How do I capture the log output from sshd when running it as a service?

Might be the seem issue as #1399.

EDIT: Nevermind, my issue was not having proper permissions set on ~/.authorized_keys.

@aJesus37
Copy link

Hello.
Came here searching for the error I was having, same as title.
Turned out I was trying to log in as Administrator whereas my computer had other user as the administrator, so no user Administrator ever existed.
Hope it helps.

@MarkFanBiao
Copy link

I am facing this issue as well. How do I capture the log output from sshd when running it as a service?

Might be the seem issue as #1399.

EDIT: Nevermind, my issue was not having proper permissions set on ~/.authorized_keys.

Add below lines to %programdata%\ssh\sshd_config,
SyslogFacility LOCAL0
LogLevel DEBUG3

@maertendMSFT
Copy link
Collaborator

Please try the latest release. Feel free to reopen or create a new issue if you run into this issue again.

@dfields-msft
Copy link

@maertendMSFT I'm still seeing this problem with the latest version (OpenSSH_for_Windows_8.1p1); is there another active issue tracking this? Anything I can do to help diagnose? Or do I not actually have the latest version (I followed instructions here: https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH)?

@dfields-msft
Copy link

Looks like #1543 might be it.

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

No branches or pull requests

8 participants