MCPcopy Create free account
hub / github.com/Driver-C/tryssh / TryLogin

Method TryLogin

pkg/control/ssh.go:22–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

20// TryLogin attempts to log in to the target server, first using cached credentials
21// and then by trying all credential combinations.
22func (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
40func (sc *SSHController) tryLoginWithCache(user string, targetServer *config.ServerListConfig) {
41 lan := &launcher.SSHLauncher{SSHConnector: *launcher.GetSSHConnectorFromConfig(targetServer)}

Calls 6

tryLoginWithCacheMethod · 0.95
tryLoginWithoutCacheMethod · 0.95
ResolveAliasFunction · 0.92
SelectServerCacheFunction · 0.92
InfofFunction · 0.92
WarnfFunction · 0.92