SCP接続はファイルのコピー後に閉じませんが、PSCPの場合は閉じます。

SCP接続はファイルのコピー後に閉じませんが、PSCPの場合は閉じます。

こんにちは、インターニッチいくつかのカスタム ハードウェア上で実行されている ssh サーバー スタック。scp コマンドを使用してサーバーからクライアント PC にいくつかのファイルをコピーしようとしましたが、ファイルを受信した後も接続が開いたままであることがわかりました。このコマンドを使用すると、問題なく正常に動作します。scp コマンドと pscp コマンドの両方に gitbash ターミナルを使用しました。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 は、特に特別な制限付きシェルが前面にある場合、接続を閉じるのに時間がかかることがあります。scp をバックグラウンドで閉じるのを待つようにすることができます (ctrl+z と bg) また、タイムアウトなどを試して、閉じるのを待つのを避けることもできます (これは、scp と pscp の間の構成/実装の違いだと思います)

関連情報