Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #22933
jdconti opened this issue Jan 27, 2023 · 2 comments · Fixed by #23626
Open
Tracked by #22933

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

jdconti opened this issue Jan 27, 2023 · 2 comments · Fixed by #23626
Assignees

Comments

@jdconti
Copy link

jdconti commented Jan 27, 2023

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:

  • Teleport version: 11.2.1
  • OpenSSH version: 9.0p1
  • Recreation steps touch testfile; scp testfile user@host:/tmp; echo $? and observe non-zero exit code
  • Debug logs
scp: debug3: source_sftp: copying local test to remote /tmp/test
scp: debug2: do_upload: upload local "test" to remote "/tmp/test"
scp: debug2: Sending SSH2_FXP_OPEN "/tmp/test"
scp: debug3: Sent dest message SSH2_FXP_OPEN I:2 P:/tmp/test M:0x001a
debug2: channel 0: rcvd adjust 34
test                                                                                                                                                                                                                                                     100%    0     0.0KB/s   00:00
scp: debug3: Sent message SSH2_FXP_CLOSE I:3
debug2: channel 0: rcvd adjust 14
scp: debug3: SSH2_FXP_STATUS 0
debug2: channel 0: read failed rfd 3 maxlen 32768: Broken pipe
debug2: channel 0: read failed
debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 3 efd 7 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug2: channel 0: output open -> drain
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i3 o1 sock -1 wfd 6 efd 7 [write])
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/7 sock -1 cc -1 io 0x00/0x00)

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
Copy link
Contributor

jakule commented Mar 23, 2023

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

jakule added a commit that referenced this issue Mar 26, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
@jakule jakule closed this as completed in 68a3bd6 Mar 28, 2023
github-actions bot pushed a commit that referenced this issue Mar 28, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
github-actions bot pushed a commit that referenced this issue Mar 28, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
github-actions bot pushed a commit that referenced this issue Mar 28, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
jakule added a commit that referenced this issue Mar 31, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
jakule added a commit that referenced this issue Mar 31, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
jakule added a commit that referenced this issue Mar 31, 2023
Go SFTP doesn't return error code as mentioned here pkg/sftp#321. As a consequence of that `scp` returns error code 1 if no code wa returned for the server, which makes it look like something went wrong even on successful transfer.

This PR adds the return code to the SFTP subsystem, which fixes the described behavior.

Closes #20863

Note: The error code is not returned when using OpenSSH server and client. This PR only fixes the behavior when Teleport is used as a server. Here is an issue tro trace it #23625
@Joerger
Copy link
Contributor

Joerger commented Nov 1, 2024

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

@Joerger Joerger reopened this Nov 1, 2024
@Joerger Joerger assigned Joerger and unassigned jakule Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants