mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-30 13:56:40 -04:00
Support passphrase-protected SSH identity files on non-CLI clients
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ func GetSSHClient(manualSync bool) (*ssh.Client, string, bool) {
|
||||
if keyFileProtected != "true" {
|
||||
parsedKey, err = ssh.ParsePrivateKey(key)
|
||||
} else {
|
||||
parsedKey, err = ssh.ParsePrivateKeyWithPassphrase(key, inputKeyFilePassphrase())
|
||||
parsedKey, err = ssh.ParsePrivateKeyWithPassphrase(key, core.PassphraseInputFunction("Enter passphrase for your SSH keyfile:"))
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(core.AnsiError+"Sync failed - Unable to parse private key:", keyFile+core.AnsiReset)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// inputKeyFilePassphrase prompts the user for a passphrase for an SSH key file.
|
||||
// TODO support non-CLI implementations
|
||||
func inputKeyFilePassphrase() []byte {
|
||||
fmt.Print("\nEnter passphrase for your SSH keyfile: ")
|
||||
passphrase, _ := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
fmt.Println()
|
||||
return passphrase
|
||||
}
|
||||
Reference in New Issue
Block a user