scp connection closed错误解决记录
10/21
本文最后更新于
2023年10月21日,已超过
498天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
使用scp
传输数据到一台服务器,遇到以下错误:
subsystem request failed on channel 0
scp: Connection closed
加上-v
选项输出详细信息
debug1: Sending subsystem: sftp
debug1: client_global_hostkeys_private_confirm: server used untrusted RSA signature algorithm ssh-rsa for key 0, disregarding
debug1: update_known_hosts: known hosts file /home/user/.ssh/known_hosts2 does not exist
subsystem request failed on channel 0
scp: Connection closed
说明是sftp subsystem有问题,猜测是关闭了SFTP subsystem功能。
解决方法:加上-O
选项。
scp -O test.f90 test@host:~/
-O
选项介绍
-O Use the legacy SCP protocol for file transfers instead of the SFTP protocol. Forcing the use of the SCP protocol may be necessary for servers that do not implement SFTP, for backwards-compatibility for particular filename wildcard patterns and for expanding paths with a ‘~’ prefix for older SFTP servers.
该选项用途就是使用较早的SCP协议代替SFTP协议传输文件。
如果管理员将SFTP subsystem功能关闭,如何使用sftp命令和sshfs命令。
sshd正常配置的话,sftp subsystem配置信息如下:/etc/ssh/sshd_config
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
- sftp
sftp需要显式指定-s /usr/libexec/openssh/sftp-server
sftp -s /usr/libexec/openssh/sftp-server test@host
- sshfs
sshfs使用SFTP功能挂载远程文件系统,需要SFTP支持,因此添加选项-o sftp_server=/usr/libexec/openssh/sftp-server

