MCPcopy Create free account
hub / github.com/evilsocket/shellz / authFromAgent

Function authFromAgent

session/ssh_utils.go:19–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17)
18
19func authFromAgent() (err error, auth ssh.AuthMethod) {
20 log.Debug("asking for ssh key to %s", SSHAuthSock)
21
22 if socket := os.Getenv(SSHAuthSock); socket == "" {
23 err = fmt.Errorf("error while connecting to ssh-agent (cant find %s variable)", SSHAuthSock)
24 } else if conn, err := net.Dial("unix", socket); err != nil {
25 err = fmt.Errorf("error while connecting to ssh-agent '%s': %s", socket, err)
26 } else {
27 auth = ssh.PublicKeysCallback(agent.NewClient(conn).Signers)
28 }
29 return
30}
31
32func authFromFile(sh models.Shell) (err error, auth ssh.AuthMethod) {
33 log.Debug("loading ssh key from %s ...", sh.Identity.KeyFile)

Callers 1

sh2ClientConfigFunction · 0.85

Calls 1

DebugMethod · 0.80

Tested by

no test coverage detected