Support passphrase-protected SSH identity files on non-CLI clients

This commit is contained in:
2024-12-28 15:09:17 -05:00
parent 1b9237af0b
commit a4a39a3a99
8 changed files with 22 additions and 35 deletions
+1 -1
View File
@@ -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)
-17
View File
@@ -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
}