From ac88ee75c92c889b97e05591e9a39b6480c538b3 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Fri, 22 Nov 2019 16:49:02 -0500 Subject: [PATCH] ssh/agent: fix example 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 --- ssh/agent/example_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ssh/agent/example_test.go b/ssh/agent/example_test.go index 8556225..1fedaea 100644 --- a/ssh/agent/example_test.go +++ b/ssh/agent/example_test.go @@ -13,20 +13,20 @@ 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(), @@ -34,8 +34,8 @@ func ExampleClientAgent() { 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() }