cmd/ssh-chat: Use x/term instead of howeyc/gopass, update prompt

Fixes #380
This commit is contained in:
Andrey Petrov 2021-03-26 12:26:18 -04:00
parent 4840634434
commit 3f81d84cf1

View File

@ -4,9 +4,10 @@ import (
"fmt"
"io/ioutil"
"os"
"syscall"
"github.com/howeyc/gopass"
"golang.org/x/crypto/ssh"
"golang.org/x/term"
)
// ReadPrivateKey attempts to read your private key and possibly decrypt it if it
@ -24,8 +25,8 @@ func ReadPrivateKey(path string) (ssh.Signer, error) {
} else if _, ok := err.(*ssh.PassphraseMissingError); ok {
passphrase := []byte(os.Getenv("IDENTITY_PASSPHRASE"))
if len(passphrase) == 0 {
fmt.Print("Enter passphrase: ")
passphrase, err = gopass.GetPasswd()
fmt.Println("Enter passphrase to unlock identity private key:", path)
passphrase, err = term.ReadPassword(int(syscall.Stdin))
if err != nil {
return nil, fmt.Errorf("couldn't read passphrase: %v", err)
}