![无法 sftp:返回 128“sftp 服务器是否正在运行”](https://linux22.com/image/1436/%E6%97%A0%E6%B3%95%20sftp%EF%BC%9A%E8%BF%94%E5%9B%9E%20128%E2%80%9Csftp%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%98%AF%E5%90%A6%E6%AD%A3%E5%9C%A8%E8%BF%90%E8%A1%8C%E2%80%9D.png)
我可以 ssh 到我的 EC2 实例(amazon linux)(同一用户,同一台机器,同一证书),但是我无法再使用 sftp。
通过 WinScp(通过我的 windows7 盒子)登录 SFTP 曾经可以工作,但现在它给我“退出代码 128,sftp 正在运行”,错误日志只显示“sftp 的子系统请求”
我怎样才能让它发挥作用?
调试提供了这个:
debug1: session_open: channel 0
debug1: session_open: session 0: link with channel 0
debug1: server_input_channel_open: confirm session
debug1: server_input_channel_req: channel 0 request [email protected] reply 0
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req [email protected]
debug1: server_input_channel_req: channel 0 request [email protected] reply 1
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req [email protected]
debug1: temporarily_use_uid: 222/500 (e=222/500)
debug1: restore_uid: (unprivileged)
debug2: fd 8 setting O_NONBLOCK
debug1: channel 1: new [auth socket]
debug1: server_input_channel_req: channel 0 request subsystem reply 1
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req subsystem
subsystem request for sftp
debug1: subsystem: exec() /usr/libexec/openssh/sftp-server
debug2: fd 5 setting TCP_NODELAY
debug2: fd 11 setting O_NONBLOCK
debug2: fd 10 setting O_NONBLOCK
debug1: Received SIGCHLD.
debug1: session_by_pid: pid 10940
debug1: session_exit_message: session 0 channel 0 pid 10940
debug2: channel 0: request exit-signal confirm 0
debug1: session_exit_message: release channel 0
debug2: channel 0: write failed
debug2: channel 0: close_write
debug2: channel 0: send eow
debug2: channel 0: output open -> closed
debug2: channel 0: read<=0 rfd 11 len 0
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain -> closed
debug2: channel 0: send close
debug2: notify_done: reading
debug2: channel 0: rcvd close
debug2: channel 0: is dead
debug2: channel 0: gc: notify user
debug1: session_by_channel: session 0 channel 0
debug1: session_close_by_channel: channel 0 child 0
debug1: session_close: session 0 pid 0
debug2: channel 0: gc: user detached
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: server-session, nchannels 2
Connection closed by 1.2.3.4
debug1: channel 1: free: auth socket, nchannels 1
debug1: do_cleanup
debug1: temporarily_use_uid: 222/500 (e=222/500)
debug1: restore_uid: (unprivileged)
Transferred: sent 2472, received 2224 bytes
Closing connection to 1.2.3.4 port 42647
debug1: PAM: cleanup
debug1: PAM: closing session
debug1: PAM: deleting credentials
更新:问题是我编辑了 .bashrc,它向标准输出输出了一些内容。由于 sftp 为用户启动了一个新的 shell,但不喜欢那样......它会失败,退出代码为 128。
答案1
Subsystem sftp <path>
在 sshd 配置中查找/etc/ssh/sshd_config
.确保<path>
指向 SFTP 服务器(路径各不相同,但通常以 结尾openssh/sftp-server
)。确保所述服务器可执行。
$ grep sftp /etc/ssh/sshd_config 子系统 sftp /usr/lib/openssh/sftp-server $ /usr/lib/openssh/sftp-server -h 用法:sftp-server [-ehR] [-f log_facility] [-l log_level] [-u umask]
尝试在备用端口上以调试模式运行 sshd:
#sshd-rddp 1234
它应该显示子系统请求失败的确切原因。