当前位置: 首页 > news >正文

rsync scp无法使用,踩坑破解之道!

问题

scp 文件或目录 无反应

rsync 报错

protocol version mismatch -- is your shell clean?
(see the rsync manpage for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(622) [sender=3.2.7]

以为是版本问题,其实根本不是(别问我是怎么知道,问就是我用了半天的时间手动安装升级成功了,但然并卵)

参考文章

protocol version mismatch — is your shell clean? – 月下博客

文中提到

仔细看命令参数,确认不存在错误。上网查了一下,似乎没说具体原因。于是根据错误提示,用 man 查看 rsync 文档,搜索 “mismatch”,发现如下说明:

rsync occasionally produces error messages that may seem a little cryptic. The one that
seems to cause the most confusion is "protocol version mismatch -- is your shell clean?".This message is usually caused by your startup scripts or remote shell facility producing
unwanted garbage on the stream that rsync is using for its transport. The way to diagnose
this problem is to run your remote shell like this:ssh remotehost /bin/true > out.datthen look at out.dat. If everything is working correctly then out.dat should be a zero
length file. If you are getting the above error from rsync then you will probably find that
out.dat contains some text or data. Look at the contents and try to work out what is pro‐
ducing it. The most common cause is incorrectly configured shell startup scripts (such as
.cshrc or .profile) that contain output statements for non-interactive logins.

看来这个错误比较常见,因此特意说明了原因及测试方法。根据文档提示,原因可能是 .bashrc 等文件中输出了内容。登录到新买的vps,打开 .bashrc,果然看到这么一段:cat /etc/motd。不管 /etc/motd 有没有内容,这条语句都会让shell连过去时输出一行。

找到了原因,解决办法也很简单:注释掉输出语句。再回过头测试 rsync,按照预期进行文件同步,一切正常。

解决之道

这说明什么,当通过ssh远程同步或复制时,连上后,提示信息干扰了传输!

这个目标主机是欧拉服务器,有这么个信息,上图:

欧拉openEuler系统的关键点

找半天,终于:/etc/profile.d/system-info.sh 是这东西搞的鬼!

备份文件后世界核平~

cd /etc/profile.d/
mv system-info.sh system-info.shbak

其它可能产生干扰的地方:

~/.bash_profile

~/.bashrc

/etc/motd

http://www.dtcms.com/a/338153.html

相关文章:

  • 代理模式深度解析:从静态代理到 Spring AOP 实现
  • WAIC点燃人形机器人热潮,诠视SeerSense® DS80:多感融合的空间感知中枢,重新定义机器三维认知
  • 8月更新!Windows 10 22H2 64位 五合一版【原版+优化版、版本号:19045.6159】
  • 红日靶场01<超水版>
  • IDEA的创建与使用(2017版本)
  • 如何用企业微信AI 破解金融服务难题?
  • [Code Analysis] docs | Web应用前端
  • 深入解析:如何设计灵活且可维护的自定义消息机制
  • Spring AI + MCP Client 配置与使用详解
  • 专业高效的汽车部件FMEA解决方案--全星FMEA软件系统在汽车部件行业的应用优势
  • 百胜软件亮相CCDS2025-中国美妆数智科技峰会,解码美妆品牌数智化转型新路径
  • 【C语言16天强化训练】从基础入门到进阶:Day 2
  • 氯化铈:绿色科技的推动力
  • Tomcat Context的核心机制
  • LLM - windows下的Dify离线部署:从镜像打包到无网环境部署(亲测)
  • 【Goland】:Map
  • Golang資源分享
  • 第一阶段C#基础-13:索引器,接口,泛型
  • 线性调频信号(LFM)在雷达中的时域及频域MATLAB编程
  • 基于SFM的三维重建MATLAB程序
  • 分析慢查询
  • PPIO Agent沙箱:兼容E2B接口,更高性价比
  • 【DL学习笔记】损失函数各个类别梳理
  • STM32使用WS2812灯环
  • 中科米堆CASAIM自动蓝光三维测量系统检测金属结构零件尺寸
  • 机器学习项目分享之实现智能的矿物识别系统(一)
  • 浅析容器运行时
  • 【网络安全实验报告】实验八:社会工程学实验
  • 3.2 结构化输出简介
  • 常见的排序算法