我有两台 Mac,均通过“系统偏好设置”>“共享”>“远程登录:开启”启用了 sshd。我可以成功登录这两台 Mac,并使用以下命令在交互式 shell 中运行命令
$ ssh <hostname>.local
我正在使用简单密码验证(没有 SSH 密钥),并且已确认sudo sshd -t
没有问题sshd_config
。
但是,如果我尝试在远程机器上仅执行一条命令,
$ ssh <hostname>.local echo foo
命令失败(IE,退出状态 1 / 没有任何内容STDOUT
)。具体来说,详细(调试)输出似乎看起来几乎与我在 Linux VPS 上成功执行该命令时得到的结果相同 — — 唯一的区别是退出状态:
Mac主机
$ ssh -v <hostname>.local echo foo 2>&1 | tail -n10
Password:
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: echo foo
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2300, received 2552 bytes, in 0.0 seconds
Bytes per second: sent 86838.6, received 96353.1
debug1: Exit status 1
Linux VPS 主机
$ ssh -v <vps> echo foo 2>&1 | tail
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: echo foo
foo
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 3304, received 2744 bytes, in 0.3 seconds
Bytes per second: sent 11505.5, received 9555.4
debug1: Exit status 0
此外, 也scp
失败了lost connection
。
这里发生了什么?