TryLogin attempts to log in to the target server, first using cached credentials and then by trying all credential combinations.
(user string, concurrency int, sshTimeout time.Duration)
| 20 | // TryLogin attempts to log in to the target server, first using cached credentials |
| 21 | // and then by trying all credential combinations. |
| 22 | func (sc *SSHController) TryLogin(user string, concurrency int, sshTimeout time.Duration) { |
| 23 | sc.sshTimeout = sshTimeout |
| 24 | sc.concurrency = concurrency |
| 25 | sc.targetIP = config.ResolveAlias(sc.targetIP, sc.configuration) |
| 26 | var targetServer *config.ServerListConfig |
| 27 | targetServer, sc.cacheIndex, sc.cacheIsFound = config.SelectServerCache(user, sc.targetIP, sc.configuration) |
| 28 | if user != "" { |
| 29 | utils.Infof("Specify the username \"%s\" to attempt to login to the server.\n", user) |
| 30 | } |
| 31 | if sc.cacheIsFound { |
| 32 | utils.Infof("The cache for %s is found, which will be used to try.\n", sc.targetIP) |
| 33 | sc.tryLoginWithCache(user, targetServer) |
| 34 | } else { |
| 35 | utils.Warnf("The cache for %s could not be found. Start trying to login.\n\n", sc.targetIP) |
| 36 | sc.tryLoginWithoutCache(user) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func (sc *SSHController) tryLoginWithCache(user string, targetServer *config.ServerListConfig) { |
| 41 | lan := &launcher.SSHLauncher{SSHConnector: *launcher.GetSSHConnectorFromConfig(targetServer)} |