(sh models.Shell, timeouts core.Timeouts)
| 45 | } |
| 46 | |
| 47 | func 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 | } |
no test coverage detected