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

x/crypto/ssh: possible missing stdout? #27014

Closed
snoowman opened this issue Aug 15, 2018 · 7 comments
Closed

x/crypto/ssh: possible missing stdout? #27014

snoowman opened this issue Aug 15, 2018 · 7 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@snoowman
Copy link

Please answer these questions before submitting your issue. Thanks!

What did you do?

code is here: very basic ssh run command
https://play.golang.org/p/eYDOY1qg6aJ

ssh server is an embed system running dropbear.
SSH-2.0-dropbear_2016.73

Using Python Pamiko and OpenSSH client works just fine.

debug info:
2018/08/15 19:25:23 send global(1): ssh.channelOpenMsg{ChanType:"session", PeersID:0x1, PeersWindow:0x200000, MaxPacketSize:0x8000, TypeSpecificData:[]uint8(nil)}
2018/08/15 19:25:23 decoding(1): 91 &ssh.channelOpenConfirmMsg{PeersID:0x1, MyID:0x0, MyWindow:0x6000, MaxPacketSize:0x7ff7, TypeSpecificData:[]uint8{}} - 17 bytes
2018/08/15 19:25:23 send(1): ssh.channelRequestMsg{PeersID:0x0, Request:"exec", WantReply:true, RequestSpecificData:[]uint8{0x0, 0x0, 0x0, 0x4, 0x68, 0x65, 0x6c, 0x70}}
2018/08/15 19:25:23 decoding(1): 99 &ssh.channelRequestSuccessMsg{PeersID:0x1} - 5 bytes
2018/08/15 19:25:23 send(1): ssh.channelEOFMsg{PeersID:0x0}
2018/08/15 19:25:23 decoding(1): data packet - 12 bytes
2018/08/15 19:25:23 send(1): ssh.windowAdjustMsg{PeersID:0x0, AdditionalBytes:0x3}
2018/08/15 19:25:23 decoding(1): data packet - 55 bytes
2018/08/15 19:25:23 decoding(1): 96 &ssh.channelEOFMsg{PeersID:0x1} - 5 bytes
2018/08/15 19:25:23 send(1): ssh.windowAdjustMsg{PeersID:0x0, AdditionalBytes:0x2e}
2018/08/15 19:25:23 decoding(1): 98 &ssh.channelRequestMsg{PeersID:0x1, Request:"exit-status", WantReply:false, RequestSpecificData:[]uint8{0x0, 0x0, 0x0, 0x0}} - 25 bytes
2018/08/15 19:25:23 decoding(1): 97 &ssh.channelCloseMsg{PeersID:0x1} - 5 bytes
2018/08/15 19:25:23 send(1): ssh.channelCloseMsg{PeersID:0x0}

What did you expect to see?

capture all of the SSH output

What did you see instead?

just "Bye bye. Have a nice day!!!"
Which is what the CLI send when exiting.
It show that ssh is connecting but output for the commands seems to be missing.

System details

go version go1.10.3 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/x/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/x/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2_/g6jgpj8x36g41j7wm08xtzxw0000gn/T/go-build612508101=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.10.3 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.10.3
uname -v: Darwin Kernel Version 15.6.0: Thu Jun 21 20:07:40 PDT 2018; root:xnu-3248.73.11~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.11.6
BuildVersion:	15G22010
lldb --version: lldb-360.1.70
@gopherbot gopherbot added this to the Unreleased milestone Aug 15, 2018
@agnivade
Copy link
Contributor

@hanwen

@hanwen
Copy link
Contributor

hanwen commented Aug 16, 2018

the trace looks perfectly valid. You could try to insert some sleep statements in CombinedOutputs().

I bet dropbear is doing something wrong with their synchronization.

@snoowman
Copy link
Author

Thank you. I strongly suspect that dropbear is the culprit as well.
I will try sleep and run some command(ping and tcpdump on the destination host) to see if the commands are being executed at all.

@agnivade agnivade added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 16, 2018
@snoowman
Copy link
Author

seems like the command are not even being executed.
It just connect and exit. Hence no output were captured.
This is not a bug on x/crypto/ssh.

Any tip on how to further trouble shoot this only from the client side?
I can't do much debugging on the host side since it's a limited shell.

My naive approached would be to exam each of the ssh layers.
channel/session/pty/shell and etc.

@hanwen
Copy link
Contributor

hanwen commented Aug 16, 2018

CombinedOutput() is just shorthand for a couple of other commands. You copy & paste that code, and remove the bits that close channels etc.

@hanwen
Copy link
Contributor

hanwen commented Aug 16, 2018

you can also compare with openssh doing

ssh -vvvv

and see how Go and SSH traces are different.

@agnivade
Copy link
Contributor

Does not seem like there is a Go bug here. Closing. Feel free to ask around in the forums on how to debug this better.

@golang golang locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants