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: unexpected empty user field for client conn #45249

Closed
povsister opened this issue Mar 26, 2021 · 3 comments
Closed

x/crypto/ssh: unexpected empty user field for client conn #45249

povsister opened this issue Mar 26, 2021 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@povsister
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.15.6 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
It's not necessary here.

What did you do?

After using golang.org/x/crypto/ssh to connect to server successfully, unable to retrieve username used to connect to server.

sshCfg := &ssh.ClientConfig{
    User: "root",
    Auth: []ssh.AuthMethod{
	    ssh.Password("testpw"),
    },
    HostKeyCallback: ssh.InsecureIgnoreHostKey(),
    Timeout: 3 * time.Second,
}

sshClient, _ := ssh.Dial("tcp", "test.server:22", sshCfg)

fmt.Println(sshClient.User())
// gives empty string

What did you expect to see?

fmt.Println(sshClient.User())
// should print "root"

What did you see instead?

Server-side connection does not have this problem. The username at client-side seems to be dropped by accident here.
https://github.com/golang/crypto/blob/0c34fe9e7dc2486962ef9867e3edb3503537209f/ssh/client.go#L79-L81

I will open a pull-request to fix it later.

@povsister
Copy link
Author

The reason why I opened this issue is that this bug blocks me from getting the user from existing SSH client.
Without running commands on remote (e.g: whoami), it's not possible to know which user is attached to the existing connection.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/304990 mentions this issue: ssh: fix user field missing for client-side conn

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 26, 2021
@networkimprov
Copy link

cc @FiloSottile

povsister added a commit to povsister/crypto that referenced this issue Mar 29, 2021
@golang golang locked and limited conversation to collaborators May 6, 2022
LewiGoddard pushed a commit to LewiGoddard/crypto that referenced this issue Feb 16, 2023
Fix golang/go#45249

Change-Id: I27ef2976586ad481d832c6e46695a91f1bb50373
GitHub-Last-Rev: 9f631b80925719a0fb77576f7983cd7c8d0b5056
GitHub-Pull-Request: golang/crypto#180
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/304990
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
BiiChris pushed a commit to BiiChris/crypto that referenced this issue Sep 15, 2023
Fix golang/go#45249

Change-Id: I27ef2976586ad481d832c6e46695a91f1bb50373
GitHub-Last-Rev: 9f631b8
GitHub-Pull-Request: golang#180
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/304990
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants