SSH登入後關閉連線退出狀態254

SSH登入後關閉連線退出狀態254

我需要先聲明我已經閱讀了這裡與我的相關的每個問題,但所有這些問題似乎都可以以某種方式存取其伺服器的檔案。我不知道,所以這是我的問題。

我使用的是 centOS 6.5,ssh 在成功登入後立即關閉連線。我使用 mac 和 windows/putty 存取我的伺服器,結果相同。無論如何,我現在可以訪問我的伺服器而無需訪問其文件嗎?

以下是成功登入後 ssh -vvv 的讀數:

debug1: Authentication succeeded (password).
Authenticated to 4X.5X.XX.2 ([4X.5X.XX.2]:82).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 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
debug1: Sending environment.
debug3: Ignored env TERM_PROGRAM
debug3: Ignored env SHELL
debug3: Ignored env TERM
debug3: Ignored env TMPDIR
debug3: Ignored env Apple_PubSub_Socket_Render
debug3: Ignored env TERM_PROGRAM_VERSION
debug3: Ignored env TERM_SESSION_ID
debug3: Ignored env USER
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env __CF_USER_TEXT_ENCODING
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env XPC_FLAGS
debug3: Ignored env XPC_SERVICE_NAME
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Wed Oct  7 06:23:21 2015 from 1XX.XXX.X1.185
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 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)

Connection to 4X.5X.XX.2 closed.
Transferred: sent 3176, received 2640 bytes, in 0.3 seconds
Bytes per second: sent 10370.6, received 8620.4
debug1: Exit status 254

答案1

根據記錄,這肯定是分叉用戶 shell 時出現的問題。這些可能是由以下原因引起的:

  1. shell初始化檔案有問題
  2. 記憶體不足的情況
  3. 進程外條件

這是一個很晚的答案,但在這種情況下,我會嘗試直接執行命令,例如:ssh server ls -ltra它可以繞過一些shell 初始化,以另一個用戶身份登錄,該用戶將使用一些不同的shell 初始化文件,然後重新啟動,這應該會修復任何資源不足的情況。

答案2

我將核心參數檔案 /etc/security/limits.conf 中的開啟檔案配置更改為無限制,並失去了連線。

將其恢復為 root 使用者的正常狀態後,我恢復了連線。

Wrong Example:
## Example hard limit for max opened files
*        hard   nofile unlimited
root     hard   nofile  unlimited
## Example soft limit for max opened files
*        soft   nofile unlimited
root     soft   nofile unlimited

Correct Ex:
## Example hard limit for max opened files
*        hard   nofile 16000
root     hard   nofile 16000
## Example soft limit for max opened files
*        soft   nofile 16000
root     soft   nofile 16000

相關內容