1

I'm an SSH scripting novice, so I'm trying to understand whether I'm just doing it wrong or there is an issue.

Background: I'm trying to connect VSCode RemoteSSH to HuggingFace Space dev mode and VSCode gets stuck in the beginning piping a script to SSH sh and waiting for output: https://github.com/microsoft/vscode-remote-release/issues/11296

Observations:

  1. Wherever I try to pipe anything to ssh's stdin, I stop getting any STDOUT
  2. Wherever I try to pipe anything to ssh's stdin, and try to read that STDIN in the remote script, everything gets stuck
  3. The ssh -T option does not seem to have any effect

Without piping, everything works:

>ssh.exe "[email protected]" "whoami; echo BBB; exit 42" channel 0: protocol error: close rcvd twice user BBB 

Piping anything results in nothing being printed (the program is still being executed and has exit status 42):

>echo "whoami" | ssh.exe "[email protected]" "whoami; echo BBB; exit 42" channel 0: protocol error: close rcvd twice 

Trying to access stdin causes everything to get stuck forever:

>echo "whoami" | ssh.exe "[email protected]" "whoami; echo BBB; cat /dev/stdin; exit 42" 

The remote shells are bash and dash:

C:\Users\Ark>ssh.exe "[email protected]" "xxx" channel 0: protocol error: close rcvd twice bash: line 1: xxx: command not found C:\Users\Ark>ssh.exe "[email protected]" "echo $SHELL" channel 0: protocol error: close rcvd twice /bin/sh C:\Users\Ark>ssh.exe "[email protected]" "ls -la $SHELL" channel 0: protocol error: close rcvd twice lrwxrwxrwx. 1 root root 4 Feb 4 2025 /bin/sh -> dash 
>ssh.exe -V OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 

The remote container is using the python:3.9 base container image.

Update: Verbose

>echo "whoami" | ssh.exe -v "[email protected]" "whoami; echo BBB; exit 42" ... debug1: Entering interactive session. debug1: pledge: filesystem debug3: client_repledge: enter debug3: receive packet: type 91 debug2: channel_input_open_confirmation: channel 0: callback start debug2: fd 3 setting TCP_NODELAY debug2: client_session2_setup: id 0 debug1: Sending command: whoami; echo BBB; exit 42 debug2: channel 0: request exec confirm 1 debug3: send packet: type 98 debug3: client_repledge: enter debug2: channel_input_open_confirmation: channel 0: callback done debug2: channel 0: open confirm rwindow 2097152 rmax 32768 debug2: channel 0: read failed rfd 4 maxlen 32768: Broken pipe debug2: channel 0: read failed debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 4 efd 6 [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 99 debug2: channel_input_status_confirm: type 99 id 0 debug2: exec request accepted on channel 0 debug3: receive packet: type 98 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug3: receive packet: type 97 debug2: channel 0: rcvd close debug2: channel 0: output open -> drain debug3: receive packet: type 97 debug2: channel 0: rcvd close channel 0: protocol error: close rcvd twice 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 5 efd 6 [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 [session] r2 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1 io 0x00/0x00) debug3: send packet: type 1 Transferred: sent 3592, received 1952 bytes, in 0.3 seconds Bytes per second: sent 12013.4, received 6528.4 debug1: Exit status 42 
>echo "whoami" | ssh.exe -v "[email protected]" "whoami; echo BBB; cat /dev/stdin; exit 42" ... Authenticated to ssh.hf.space ([18.205.32.140]:22) using "publickey". debug2: fd 4 setting O_NONBLOCK debug1: channel 0: new session [client-session] (inactive timeout: 0) debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug3: send packet: type 90 debug1: Entering interactive session. debug1: pledge: filesystem debug3: client_repledge: enter debug3: receive packet: type 91 debug2: channel_input_open_confirmation: channel 0: callback start debug2: fd 3 setting TCP_NODELAY debug2: client_session2_setup: id 0 debug1: Sending command: whoami; echo BBB; cat /dev/stdin; exit 42 debug2: channel 0: request exec confirm 1 debug3: send packet: type 98 debug3: client_repledge: enter debug2: channel_input_open_confirmation: channel 0: callback done debug2: channel 0: open confirm rwindow 2097152 rmax 32768 debug2: channel 0: read failed rfd 4 maxlen 32768: Broken pipe debug2: channel 0: read failed debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 4 efd 6 [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 99 debug2: channel_input_status_confirm: type 99 id 0 debug2: exec request accepted on channel 0 # After Ctrl+C: debug3: send packet: type 1 debug1: channel 0: free: client-session, nchannels 1 debug3: channel 0: status: The following connections are open: #0 client-session (t4 [session] r2 i3/0 o0/0 e[write]/0 fd -1/5/6 sock -1 cc -1 io 0x00/0x00) Transferred: sent 3588, received 1876 bytes, in 30.4 seconds Bytes per second: sent 118.1, received 61.7 debug1: Exit status -1 
3
  • 2
    Try running with the -v option (or -vv, -vvv for increasing verbosity) to see what SSH is doing Commented Nov 6 at 7:05
  • I did run with -v. That's how I learned that the program is actually executed (exit code 42). Commented Nov 6 at 11:27
  • Added last parts of the verbose logs. Commented Nov 6 at 11:32

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.