gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.67k stars 1.77k forks source link

scp returning non-zero exit code on successful transfer #20863

Open jdconti opened 1 year ago

jdconti commented 1 year ago

Expected behavior: Transfer a file using scp -> teleport daemon (via proxy) using OpenSSH 9.0p1 and observe an exit code of zero on successful transfer.

# scp test file using teleport daemon
jdconti@foo:~$ scp test jdconti@bar:/tmp/
jdconti@bar's password:
test                                                                                                                                                                                                                                                     100%    0     0.0KB/s   00:00
# test exit code
jdconti@foo:~$ echo $?
0

Current behavior: Transfer a file using scp -> teleport daemon (via proxy) using OpenSSH 9.0p1 and observe a non-zero exit code on successful transfer.

# scp test file using teleport daemon
jdconti@foo:~$ scp test jdconti@bar:/tmp/
test                                                                                                                                                                                                                                                     100%    0     0.0KB/s   00:00
# test exit code
jdconti@foo:~$ echo $?
1

Bug details:

debug3: send packet: type 1 Transferred: sent 6440, received 4660 bytes, in 0.3 seconds Bytes per second: sent 20260.4, received 14660.5 debug1: Exit status -1

jakule commented 1 year ago

@jdconti Thanks for reporting that. I was able to reproduce the issue. Looks like it's related to this: https://github.com/pkg/sftp/issues/321 As a workaround, you can use scp -O test jdconti@bar:/tmp/ to copy files. We should have a patch soon.

Joerger commented 3 weeks ago

I get this issue with agentless nodes on v17. scp -O still works as a workaround.