File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -13,29 +13,29 @@ import (
13
13
"golang.org/x/crypto/ssh/agent"
14
14
)
15
15
16
- func ExampleClientAgent () {
17
- // ssh-agent has a UNIX socket under $SSH_AUTH_SOCK
16
+ func ExampleNewClient () {
17
+ // ssh-agent(1) provides a UNIX socket at $SSH_AUTH_SOCK.
18
18
socket := os .Getenv ("SSH_AUTH_SOCK" )
19
19
conn , err := net .Dial ("unix" , socket )
20
20
if err != nil {
21
- log .Fatalf ("net.Dial : %v" , err )
21
+ log .Fatalf ("Failed to open SSH_AUTH_SOCK : %v" , err )
22
22
}
23
+
23
24
agentClient := agent .NewClient (conn )
24
25
config := & ssh.ClientConfig {
25
- User : "username " ,
26
+ User : "gopher " ,
26
27
Auth : []ssh.AuthMethod {
27
- // Use a callback rather than PublicKeys
28
- // so we only consult the agent once the remote server
29
- // wants it.
28
+ // Use a callback rather than PublicKeys so we only consult the
29
+ // agent once the remote server wants it.
30
30
ssh .PublicKeysCallback (agentClient .Signers ),
31
31
},
32
32
HostKeyCallback : ssh .InsecureIgnoreHostKey (),
33
33
}
34
34
35
35
sshc , err := ssh .Dial ("tcp" , "localhost:22" , config )
36
36
if err != nil {
37
- log .Fatalf ( "Dial: %v" , err )
37
+ log .Fatal ( err )
38
38
}
39
- // .. use sshc
39
+ // Use sshc...
40
40
sshc .Close ()
41
41
}
You can’t perform that action at this time.
0 commit comments