Skip to content

Commit

Permalink
ssh/agent: fix example
Browse files Browse the repository at this point in the history
Since there is no ClientAgent identifier, ExampleClientAgent wasn't
displayed as an example by godoc.

Change-Id: Ied8df7d8412c4aa483d42315986af49ba8fdbcef
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/208480
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
FiloSottile committed Nov 22, 2019
1 parent 4f8c1d8 commit ac88ee7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ssh/agent/example_test.go
Expand Up @@ -13,29 +13,29 @@ import (
"golang.org/x/crypto/ssh/agent"
)

func ExampleClientAgent() {
// ssh-agent has a UNIX socket under $SSH_AUTH_SOCK
func ExampleNewClient() {
// ssh-agent(1) provides a UNIX socket at $SSH_AUTH_SOCK.
socket := os.Getenv("SSH_AUTH_SOCK")
conn, err := net.Dial("unix", socket)
if err != nil {
log.Fatalf("net.Dial: %v", err)
log.Fatalf("Failed to open SSH_AUTH_SOCK: %v", err)
}

agentClient := agent.NewClient(conn)
config := &ssh.ClientConfig{
User: "username",
User: "gopher",
Auth: []ssh.AuthMethod{
// Use a callback rather than PublicKeys
// so we only consult the agent once the remote server
// wants it.
// Use a callback rather than PublicKeys so we only consult the
// agent once the remote server wants it.
ssh.PublicKeysCallback(agentClient.Signers),
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}

sshc, err := ssh.Dial("tcp", "localhost:22", config)
if err != nil {
log.Fatalf("Dial: %v", err)
log.Fatal(err)
}
// .. use sshc
// Use sshc...
sshc.Close()
}

0 comments on commit ac88ee7

Please sign in to comment.