TypechoJoeTheme

MetMan's Blog

网站页面

scp connection closed错误解决记录

MetMan博 主
2023-10-21
/
0 评论
/
142 阅读
/
135 个字
/
百度已收录
10/21
本文最后更新于 2023年10月21日,已超过 334天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

使用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

朗读
赞(0)
赞赏
感谢您的支持,我会继续努力哒!
版权属于:

MetMan's Blog

本文链接:

https://blog.metman.top/index.php/archives/23/(转载时请注明本文出处及文章链接)

评论 (0)

互动读者

标签云

最新回复

暂无回复

登录
X
用户名
密码