檔案複製後 SCP 連線不會關閉,而 PSCP 會關閉

檔案複製後 SCP 連線不會關閉,而 PSCP 會關閉

嗨,我有一個利基國際在某些自訂硬體上執行的 ssh 伺服器堆疊。我試圖使用 scp 命令將一些文件從伺服器複製到客戶端電腦,但發現即使在我使用它的同時收到文件後,連接仍然保持打開狀態,它工作正常,沒有任何故障。我使用 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 之間配置/實現的不同從您表現出的行為來看)

相關內容