Update: The issue is only on Windows server 2008 R2
. I created a Windows server 2012 R2
VM and it works fine.
I want to run some windows query through ssh, but this is a interesting issue which I'm unable to find the cause of it.
The error I get is the following when using keys to authenticate:
root@ubunutu: ssh -t username@10.10.10.10 "schtasks /query"
ERROR: A specified logon session does not exist. It may already have been terminated.
GPO "Do not allow storage of passwords and credentials for network authentication" is already disabled.
It works fine if I use password authentication and returns the output from the query.
It also works if I start the sshd on remote cygwin server with -D
or -d
and then authenticate using keys or password.
Update: it works as long as the service is started by the same user which we authenticate. username@cygserver: /usr/sbin/sshd.exe
By default cygrunsrv --start sshd
starts as SERVER_NAME/cyg_server user.
username@cygserver: /usr/sbin/sshd.exe -D
or
username@cygserver: /usr/sbin/sshd.exe
root@ubunutu: ssh -t username@10.10.10.10 "schtasks /query"
...output of all schedule tasks
Other windows commands works fine.
Debug logs when using keys:
debug3: Ignored env LOGNAME
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env LESSCLOSE
debug3: Ignored env _
debug3: Ignored env OLDPWD
debug1: Sending command: schtasks /query
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug2: channel 0: rcvd ext data 88
ERROR: A specified logon session does not exist. It may already have been terminated.
debug2: channel 0: written 88 to efd 6
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
Debug logs when sshd is started with -D
switch and authenticating using keys.
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env LESSCLOSE
debug3: Ignored env _
debug3: Ignored env OLDPWD
debug1: Sending command: schtasks /query
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Folder: \
TaskName Next Run Time Status
======================================== ====================== ===============
test1 N/A Running
RegIdleBackup 8/6/2018 12:25:27 AM Ready
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
Folder: \Microsoft\Windows\Wininet
TaskName Next Run Time Status
======================================== ====================== ===============
test2 N/A Running
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
Transferred: sent 2712, received 13664 bytes, in 0.2 seconds
Bytes per second: sent 17373.0, received 87531.3
debug1: Exit status 0