SCP 连接在文件复制后不会关闭,而 PSCP 会关闭

SCP 连接在文件复制后不会关闭,而 PSCP 会关闭

嗨,我有一个利基市场ssh 服务器堆栈运行在某些自定义硬件上。我尝试使用 scp 命令将一些文件从服务器复制到客户端 PC,但发现即使在我同时收到文件后,连接仍然保持打开状态,当我使用它时,它工作正常,没有任何故障。我使用 gitbash 终端执行 scp 和 pscp 命令。scp [email protected]:\\path\\to\\file /local/file/pathpscp -scp [email protected]:\\path\\to\\file /local/file/path

我无法理解的是为什么这两个命令的行为存在差异,实际上是pscp用法scp不同。这是 PSCP 命令的调试日志

$ pscp -scp -v [email protected]:\\demo\\test_1.txt /d/test_1.txt    
[email protected]'s password:
Using username "user".
Sent password
Access granted
Opening session as main channel
Opened main channel
Started a shell/command
test_1.txt                | 0 kB |   0.0 kB/s | ETA: 00:00:00 | 100%
Using SCP1
Connected to 192.168.1.12
Server sent command exit status 0
Disconnected: All channels closed

这是 SCP

scp [email protected]:\\demo\\test_1.txt /d/test_1.txt
[email protected]'s password:
debug1: Authentication succeeded (password).
Authenticated to 192.168.1.12 ([192.168.1.12]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending command: scp -v -f \\demo\\test_1.txt
Sink: C0777 16 \demo\test_1.txt
\demo\test_1.txt                                                             100%   16     0.0KB/s   05:49    debug1: channel 0: free: client-session, nchannels 1
Killed by signal 2.

为什么文件复制后连接仍SCP connection remains open until I hit ctrl+c manually. 处于SCP打开状态?为什么不关闭通道?

答案1

也许您尝试与 scp 通信的计算机很慢... 您等待了多长时间才按下 CTRL+C ?有时 scp 关闭连接很慢,尤其是在前面有特殊限制的 shell 的情况下。您可以尝试将 scp 放在后台等待关闭(ctrl+z 和 bg)此外,您可以尝试使用超时或类似方法以避免等待关闭(我认为这是 scp 和 pscp 在配置/实现上的不同之处,与您展示的行为不同)

相关内容