接受公钥后 SSH 挂起

接受公钥后 SSH 挂起

我遇到了 ssh 的奇怪行为。我尝试登录名为“nfs”的 ssh 用户(例如),它接受了公钥,但挂起了。ssh [email protected]

连接后紧接着的内容ssh -vvv如下。

debug1: Authentication succeeded (publickey).
Authenticated to [REDACTED].
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.
debug1: Remote: Forced command.
debug1: Remote: Forced command.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: 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 TERM
debug3: Ignored env SHELL
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
debug3: Ignored env APPLICATION_ENV
debug3: Ignored env JAVA_HOME
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 HOME
debug3: Ignored env SHLVL
debug3: Ignored env LOGNAME
debug3: Ignored env SECURITYSESSIONID
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

看起来是这样接受密钥并连接,但没有给出提示。我可以以另一个用户身份登录,然后 su 进入“nfs”用户(我得到了一个 bash 提示),所以我知道用户配置没问题。但有些东西阻止了直接 ssh 连接。我不确定这些日志条目是什么意思。有人能帮忙吗?

答案1

debug1: Remote: Forced command.表明您登录时使用的公钥指定了要运行的命令,因此您不会获得 shell。检查nfs用户authorized_keys文件,看看您使用的密钥是否command="command"附加了指令。如果是,您必须删除它,或者使用不同的密钥对,或者使用密码验证等。

相关内容