无法 ssh,连接立即终止,退出状态为 254

the*_*cer 16 shell ssh ulimit

我记得最近的事情是将软硬内存锁 ulimit 更改为无限制。现在我无法通过 ssh 进入机器。

这是 ssh 日志。

Authenticated to IP ([IP]:22).
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug1: Sending env LC_CTYPE = 
debug2: channel 0: request env confirm 0
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 Aug  6 07:18:07 2014 from IP-SOURCE
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
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 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
Connection to IP closed.
Transferred: sent 4256, received 2504 bytes, in 0.4 seconds
Bytes per second: sent 9616.9, received 5658.0
debug1: Exit status 254
Run Code Online (Sandbox Code Playgroud)

在发布到这里之前,我已经尝试了以下失败的方法:

  1. 尝试通过 Norc noprofile 登录 ssh user@host 'bash --noprofile'

  2. 强制使用 tty ssh -t user@host

  3. 移动了 bash_profile。尝试通过 sshing ssh user@host

  4. 重命名limits.conf文件,希望它不会被读取。

  5. 重新启动 ssh 服务器。

  6. 通过knifeas运行命令knife ssh "name:server" "come_command"

  7. ssh user@host 'ulimit -l 64', ssh user@host 'ulimit -S -l 64', ssh user@host 'ulimit -H -l 64',ssh user@host 'exec ulimit -H -l 64'

我不确定这种运行命令的方式 inline: 是否ssh user@host "some_command"有效,因为我无法获得简单的目录列表。我也尝试通过重新启动ssh user@host 'reboot'但不认为该命令已执行。我也从 AWS 重新启动了机器,但没有成功。

尝试 ssh 是失败的原因吗?有什么办法可以通过 ssh 进入服务器吗?

小智 14

尝试改变

UsePAM yes
Run Code Online (Sandbox Code Playgroud)

UsePAM no
Run Code Online (Sandbox Code Playgroud)

in /etc/ssh/sshd_config(CentOS)

  • 它有效,但为什么呢? (2认同)

Gab*_*oux 5

我遇到了类似的问题,我似乎只看到以下奇怪的消息:

client_input_channel_req: channel 0 rtype exit-status reply 0.
Run Code Online (Sandbox Code Playgroud)

我试图ssh进入的用户没有默认 shell

我运行了以下命令:

chsh -s $(which sh) username 
Run Code Online (Sandbox Code Playgroud)

然后我就能够了ssh

笔记:

运行su username返回退出代码1(失败),现在它可以正常工作了。