Linux 下升级 OpenSSH 到 9.x 版本对 scp 影响
背景说明
- scp 命令 -- 执行文件拷贝
- 源文件 -- testscp.txt
- 目标文件 -- testscp.txt
- 目标机器、目标路径 -- 本机、当前目录 -- 相当于覆盖拷贝
模拟执行过程
openssh 版本说明
[root@localhost ~]$ ssh -V
OpenSSH_9.0p1, OpenSSL 1.0.2l 25 May 2017
[root@localhost ~]$ openssl version
OpenSSL 1.0.2l 25 May 2017
模拟过程
[root@localhost ~]$ echo "111" > testscp.txt
[root@localhost ~]$ cat testscp.txt
111
[root@localhost ~]$ scp testscp.txt root@192.168.68.129:/root/testscp.txt
testscp.txt 0% 0 0.0KB/s --:-- ETA
[root@localhost ~]$ cat testscp.txt
对比执行差异
OpenSSH 8.x 版本 – 执行 – 成功
- openssh 版本 -- 8.x
- 源文件 -- testscp.txt
- 源目录 -- /root/testscp.txt
- 目标主机 -- 当前主机
- 目标文件 -- testscp.txt
- 目标目录 -- /root/testscp.txt
- scp 结果 -- 成功
debug1: Sending command: scp -v -t /home/dev/testscp.txt
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Sending file modes: C0664 4 testscp.txt
debug2: channel 0: rcvd ext data 26
Sink: C0664 4 testscp.txt
debug2: channel 0: written 26 to efd 6
testscp.txt 100% 4 5.1KB/s 00:00
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed
OpenSSH 9.0 版本 – 执行 – 失败
- openssh 版本 -- 9.x
- 源文件 -- testscp.txt
- 源目录 -- /root/testscp.txt
- 目标主机 -- 当前主机
- 目标文件 -- testscp.txt
- 目标目录 -- /root/testscp.txt
- scp 结果 -- 失败
scp: debug2: do_upload: upload local "testscp.txt" to remote "/root/testscp.txt"
scp: debug2: Sending SSH2_FXP_OPEN "/root/testscp.txt"
scp: debug3: Sent dest message SSH2_FXP_OPEN I:3 P:/root/testscp.txt M:0x001a
testscp.txt 0% 0 0.0KB/s --:-- ETA
scp: debug3: Sent message SSH2_FXP_CLOSE I:4
scp: debug3: SSH2_FXP_STATUS 0
debug2: channel 0: read failed rfd 4 maxlen 32768: Broken pipe
OpenSSH 9.0 版本 – 执行 – 失败
- openssh 版本 -- 9.x
- 源文件 -- testscp.txt
- 源目录 -- /root/testscp.txt
- 目标主机 -- 当前主机
- 目标文件 -- testscp.txt
- 目标目录 -- /tmp/testscp.txt
- scp 结果 -- 成功
scp: debug2: do_upload: upload local "testscp.txt" to remote "/tmp/testscp.txt"
scp: debug2: Sending SSH2_FXP_OPEN "/tmp/testscp.txt"
scp: debug3: Sent dest message SSH2_FXP_OPEN I:3 P:/tmp/testscp.txt M:0x001a
testscp.txt 0% 0 0.0KB/s --:-- ETA
scp: debug3: Sent message SSH2_FXP_WRITE I:5 O:0 S:4
scp: debug3: SSH2_FXP_STATUS 0
scp: debug3: In write loop, ack for 5 4 bytes at 0
testscp.txt 100% 4 19.1KB/s 00:00
scp: debug3: Sent message SSH2_FXP_CLOSE I:4
scp: debug3: SSH2_FXP_STATUS 0
debug2: channel 0: read failed rfd 4 maxlen 32768: Broken pipe
解决办法
命令使用
[root@localhost ~]$ scp -O testscp.txt root@192.168.68.129:/root/testscp.txt
testscp.txt 100% 0 0.0KB/s 00:00
别名配置
[root@localhost ~]$ grep alias /etc/profile
alias scp='scp -O'
参考