Atualização: o problema está apenas em Windows server 2008 R2
. Eu criei um Windows server 2012 R2
VM e funciona bem.
Eu quero executar algumas consultas do Windows por meio do ssh, mas esse é um problema interessante que não consigo encontrar a causa dele.
O erro que recebo é o seguinte ao usar as chaves para autenticar:
root@ubunutu: ssh -t [email protected] "schtasks /query"
ERROR: A specified logon session does not exist. It may already have been terminated.
O GPO "Não permitir armazenamento de senhas e credenciais para autenticação de rede" já está desativado.
Funciona bem se eu usar a autenticação por senha e retornar a saída da consulta.
Também funciona se eu iniciar o sshd no cygwin server remoto com -D
ou -d
e depois autenticar usando chaves ou senha.
Atualização: funciona desde que o serviço seja iniciado pelo mesmo usuário que autenticamos. username@cygserver: /usr/sbin/sshd.exe
Por padrão, cygrunsrv --start sshd
inicia como usuário SERVER_NAME / cyg_server.
username@cygserver: /usr/sbin/sshd.exe -D
or
username@cygserver: /usr/sbin/sshd.exe
root@ubunutu: ssh -t [email protected] "schtasks /query"
...output of all schedule tasks
Outros comandos do Windows funcionam bem.
Depurar registros ao usar chaves:
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 [email protected] 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)
Depure os logs quando o sshd for iniciado com -D
e autentique usando chaves.
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 [email protected] 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