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

Function sh2ClientConfig

session/ssh_utils.go:47–76  ·  view source on GitHub ↗
(sh models.Shell, timeouts core.Timeouts)

Source from the content-addressed store, hash-verified

45}
46
47func sh2ClientConfig(sh models.Shell, timeouts core.Timeouts) (error, *ssh.ClientConfig) {
48 authMethods := []ssh.AuthMethod{}
49 if sh.Identity.Password != "" {
50 authMethods = append(authMethods, ssh.Password(sh.Identity.Password))
51 }
52
53 if sh.Identity.KeyFile == SSHAgentKey {
54 if err, auth := authFromAgent(); err != nil {
55 return err, nil
56 } else {
57 authMethods = append(authMethods, auth)
58 }
59 } else if sh.Identity.KeyFile != "" {
60 if err, auth := authFromFile(sh); err != nil {
61 return err, nil
62 } else {
63 authMethods = append(authMethods, auth)
64 }
65 }
66
67 return nil, &ssh.ClientConfig{
68 Config: ssh.Config{
69 Ciphers: sh.Ciphers,
70 },
71 User: sh.Identity.Username,
72 Auth: authMethods,
73 Timeout: timeouts.Connect,
74 HostKeyCallback: ssh.InsecureIgnoreHostKey(),
75 }
76}

Callers 1

NewSSHFunction · 0.85

Calls 2

authFromAgentFunction · 0.85
authFromFileFunction · 0.85

Tested by

no test coverage detected