SSH 自动注销

SSH 自动注销

我正在运行命令ssh user@host,然后自动退出。

以下是添加标志的结果-vvv

debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to [host] ([IPADDR]:PORT).
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: receive packet: type 91
debug2: callback start
debug2: fd 4 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env HOSTNAME
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env HISTSIZE
debug3: Ignored env IGNOREEOF
debug3: Ignored env SSH_CLIENT
debug3: Ignored env SSH_TTY
debug3: Ignored env QT_GRAPHICSSYSTEM_CHECKED
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env KDEDIRS
debug3: Ignored env HISTCONTROL
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env QT_PLUGIN_PATH
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
You have mail.
Last login: Sat Jul 18 21:42:05 2020 from [IPADDR2]
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 98
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
debug3: receive packet: type 96
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
debug3: receive packet: type 97
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
debug3: send packet: type 97
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)

debug3: send packet: type 1
Connection to [host] closed.
Transferred: sent 2328, received 2512 bytes, in 0.0 seconds
Bytes per second: sent 222371.7, received 239947.4
debug1: Exit status 1

任何帮助调试此问题的信息都将非常感激!

答案1

根据调试输出,ssh身份验证成功。然后它在远程系统上设置了一个交互式 shell 会话。有一些文本看起来像是来自远程系统的典型欢迎消息,然后会话立即以退出代码 1 结束。

换句话说,ssh 创建了一个远程会话,但它立即关闭了。有几种情况可能会导致这种情况,但从调试跟踪中无法真正判断问题出在哪里:

  • 您的远程 shell 启动文件 (.bashrc 等) 中可能存在某些内容,导致 shell 立即退出。
  • 您的远程 shell(/bin/bash 或其他)可能有问题,导致程序无法启动。
  • 您的帐户可能已被禁用或设置为不允许以某种方式进行交互式会话。
  • 远程主机上可能存在其他问题,阻止其启动您的 shell 进程。

您可能能够或无法通过 SFTP 进入,具体取决于远程系统上 SFTP 的设置方式。如果可以通过 SFTP 进入,则可以使用它来检查、更新或删除 shell 启动文件。或者,您可能能够访问系统日志(通常在 /var/log 中)以查看是否sshd记录了有关会话终止原因的任何信息。

相关内容