从服务器到本地主机的 SCP 失败

从服务器到本地主机的 SCP 失败

我确信我之前曾通过 SCP 向服务器发送过一些文件,但现在它却无法在相反的方向上工作。

我在用着:

$ scp -v mysrv:/home/XXX/dir/app.rb app.rb.bak

Authenticated to mysrv ([88.88.111.11]:22) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype [email protected] want_reply 0
...
debug1: Sending subsystem: sftp
debug1: pledge: fork
subsystem request failed on channel 0
scp: Connection closed

答案1

在服务器日志中发现找不到SFTP子系统。

# journalctl -f
Jan 24 16:45:43 mysrv sshd[2045]: subsystem request for sftp by user XXX failed, subsystem not found

不知道它是如何被禁用的,但在配置中重新启用它解决了这个问题。只需取消注释一行即可。

# nano /etc/ssh/sshd_config 
Subsystem       sftp    /usr/lib/openssh/sftp-server

不要忘记重新启动 SSHd。

# systemctl restart ssh

仅针对搜索引擎机器人 - 这是成功的 SCP 日志:

Authenticated to mysrv ([88.88.111.11]:22) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype [email protected] want_reply 0
...
debug1: Sending subsystem: sftp
debug1: pledge: fork
scp: debug1: Fetching /home/XXX/dir/app.rb to app.rb.bak

app.rb                                                                                                                                                                                                      100%   38KB 297.3KB/s   00:00    
scp: debug1: truncating at 39240
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3248, received 42336 bytes, in 1.3 seconds
Bytes per second: sent 2528.5, received 32958.1
debug1: Exit status 0 

相关内容