SCP connection doesn't close after file copy whereas for PSCP it does

4

Hi I have an InterNiche ssh server stack running on some custom hardware. I was trying to copy some files from server to client pc using scp command like scp user@xxx.xxx.xxx.xxx:\\path\\to\\file /local/file/path but found that connection remains open even after I have received the file at the same time when I use pscp -scp user@xxx.xxx.xxx.xxx:\\path\\to\\file /local/file/path it works fine without any failure. I used gitbash terminal for both scp and pscp commands.

What I am not able to understand is why there is behavioral difference between both commands, in fact pscp use scp itself. Here is the debug log for PSCP command

$ pscp -scp -v user@192.168.1.12:\\demo\\test_1.txt /d/test_1.txt    
admin@192.168.1.12'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

and here is for SCP

scp user@192.168.1.12:\\demo\\test_1.txt /d/test_1.txt
user@192.168.1.12'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.

The SCP connection remains open until I hit ctrl+c manually. What is it which keeps SCP connection in open state even after file gets copied. Why its not closing the channel?

user7345878

Posted 2018-02-06T06:25:49.297

Reputation: 74

Answers

0

Maybe the computer you try to talk with scp is slow... how much time did you wait before hitting CTRL+C ? Sometimes scp is slow to close the connection, especially with special restricted shells in front. You can try to put the scp in background waiting the close (ctrl+z and bg) Also, you can play with timeouts or something like this to avoid waiting for close (I think that is the different in configuration/implementation between scp and pscp from the behaviour you showed)

Bertrand Cebador

Posted 2018-02-06T06:25:49.297

Reputation: 56

around 30 minutes. – user7345878 – 2018-02-06T10:31:28.000

wow ! Your problem could be related to profile scripting... : https://www.linuxquestions.org/questions/red-hat-31/scp-hangs-at-the-end-of-a-successful-transfer-739038/

– Bertrand Cebador – 2018-02-06T10:37:41.360

But I am facing this issue only with one kind of sever, rest is working fine. Means scp command works fine with other devices like BBB, Rpi, but get stuck when I connect to this server. – user7345878 – 2018-02-06T11:03:58.110

also ubuntu .bashrc contains this # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac which takes care of the problem. – user7345878 – 2018-02-06T11:15:08.100