Establish connections using bookmark ID only (#619)
* Establish connections using bookmark ID only * Refactor specs * Extra tests * Fix homedir assertion for bookmarks path * Fix newline in the warning message * Check for bookmark file existence before reading * Connect code restructure
This commit is contained in:
@@ -59,14 +59,13 @@ func parsePrivateKey(keyPath string, keyPass string) (ssh.Signer, error) {
|
||||
}
|
||||
|
||||
signer, err := ssh.ParsePrivateKey(buff)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "cannot decode encrypted private keys") {
|
||||
if keyPass == "" {
|
||||
return nil, errors.New("SSH key password is not provided")
|
||||
}
|
||||
return sshkeys.ParseEncryptedPrivateKey(buff, []byte(keyPass))
|
||||
if _, ok := err.(*ssh.PassphraseMissingError); ok {
|
||||
if keyPass == "" {
|
||||
return nil, errors.New("SSH key password is not provided")
|
||||
}
|
||||
return sshkeys.ParseEncryptedPrivateKey(buff, []byte(keyPass))
|
||||
}
|
||||
|
||||
return signer, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user