MCPcopy Index your code
hub / github.com/evilsocket/shellz / authFromFile

Function authFromFile

session/ssh_utils.go:32–45  ·  view source on GitHub ↗
(sh models.Shell)

Source from the content-addressed store, hash-verified

30}
31
32func authFromFile(sh models.Shell) (err error, auth ssh.AuthMethod) {
33 log.Debug("loading ssh key from %s ...", sh.Identity.KeyFile)
34
35 if sh.Identity.KeyFile, err = fs.Expand(sh.Identity.KeyFile); err != nil {
36 err = fmt.Errorf("error while expanding path '%s': %s", sh.Identity.KeyFile, err)
37 } else if key, err := ioutil.ReadFile(sh.Identity.KeyFile); err != nil {
38 err = fmt.Errorf("error while reading key file %s: %s", sh.Identity.KeyFile, err)
39 } else if signer, err := ssh.ParsePrivateKey(key); err != nil {
40 err = fmt.Errorf("error while parsing key file %s: %s", sh.Identity.KeyFile, err)
41 } else {
42 auth = ssh.PublicKeys(signer)
43 }
44 return
45}
46
47func sh2ClientConfig(sh models.Shell, timeouts core.Timeouts) (error, *ssh.ClientConfig) {
48 authMethods := []ssh.AuthMethod{}

Callers 1

sh2ClientConfigFunction · 0.85

Calls 1

DebugMethod · 0.80

Tested by

no test coverage detected