Debian Codegraph @

crypto/sshutil/agent_windows.go

raw symbols SCIP
1 package sshutil
2
3 import (
4 "context"
5 "net"
6 "os"
7
8 "github.com/Microsoft/go-winio"
9 "github.com/pkg/errors"
10 "golang.org/x/crypto/ssh/agent"
11 )
12
13 // dialAgent returns an ssh.Agent client. It uses the SSH_AUTH_SOCK to connect
14 // to the agent.
15 func dialAgent() (*Agent, error) {
16 // Attempt unix sockets for environments like cygwin.
17 if socket := os.Getenv("SSH_AUTH_SOCK"); socket != "" {
18 if conn, err := net.Dial("unix", socket); err == nil {
19 return &Agent{
20 ExtendedAgent: agent.NewClient(conn),
21 Conn: conn,
22 }, nil
23 }
24 }
25
26 // Windows OpenSSH agent
27 conn, err := winio.DialPipeContext(context.Background(), `\\.\\pipe\\openssh-ssh-agent`)
28 if err != nil {
29 return nil, errors.Wrap(err, "error connecting with ssh-agent")
30 }
31 return &Agent{
32 ExtendedAgent: agent.NewClient(conn),
33 Conn: conn,
34 }, nil
35 }