I have the same problem. The problem is that the server at the remote end does not send an exit code. Compare these transaction excerpts.
First reasons $? = 1 $? = 1 :
debug1: Sending command: scp -v -f /cfg/running-config Sink: C0644 3398 running-config running-config 100% 3398 3.3KB/s 00:00 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Connection to xxxxx closed by remote host. Transferred: sent 2576, received 5216 bytes, in 1.9 seconds Bytes per second: sent 1346.9, received 2727.3 debug1: Exit status -1
The second reason $?=0 :
debug1: Sending command: scp -v -f /cfg/running-config Sink: C0644 3940 running-config running-config 100% 3940 3.9KB/s 00:00 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Connection to xxxxx closed by remote host. Transferred: sent 2624, received 5984 bytes, in 1.3 seconds Bytes per second: sent 2026.8, received 4622.2
These are two HP switches on different firmware versions. The first is very old; the second is new and correctly returns exit-status reply 0 client.
source share