diff --git a/crawler/ssh/client/client.go b/crawler/ssh/client/client.go index dee7790..6ffc3b5 100644 --- a/crawler/ssh/client/client.go +++ b/crawler/ssh/client/client.go @@ -88,28 +88,24 @@ func parsePrivateKey(keyPath, pw string) (ssh.Signer, error) { return ssh.ParsePrivateKeyWithPassphrase(buff, []byte(pw)) } -func New(target *ocmsc.Target) (*SSHClient, error) { - connection := target.Connection - auth := target.Auth +func New(connection *ocmsc.SensorConfigConnection) (*SSHClient, error) { + credentials := connection.Credentials ip := connection.IP port, _ := cuej.NumberToInt(connection.Port) - user := auth["id"].(string) - pw := auth["pw"].(string) - keyFilePathObj := auth["keyFilePath"] - keyFilePath := "" + user := credentials["id"] + pw := credentials["pw"] + keyFilePath, keyFilePathExist := credentials["keyFilePath"] sshAuth := make([]ssh.AuthMethod, 0) - if keyFilePathObj != nil { - keyFilePath = keyFilePathObj.(string) + if keyFilePathExist { if "" != keyFilePath { key, err := parsePrivateKey(keyFilePath, pw) if err != nil { return nil, err } sshAuth = append(sshAuth, ssh.PublicKeys(key)) - } } sshAuth = append(sshAuth, ssh.Password(pw))