mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-07-02 03:34:29 +02:00
cmd/ssh-chat: Use x/term instead of howeyc/gopass, update prompt
Fixes #380
This commit is contained in:
parent
4840634434
commit
3f81d84cf1
@ -4,9 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/howeyc/gopass"
|
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadPrivateKey attempts to read your private key and possibly decrypt it if it
|
// 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 {
|
} else if _, ok := err.(*ssh.PassphraseMissingError); ok {
|
||||||
passphrase := []byte(os.Getenv("IDENTITY_PASSPHRASE"))
|
passphrase := []byte(os.Getenv("IDENTITY_PASSPHRASE"))
|
||||||
if len(passphrase) == 0 {
|
if len(passphrase) == 0 {
|
||||||
fmt.Print("Enter passphrase: ")
|
fmt.Println("Enter passphrase to unlock identity private key:", path)
|
||||||
passphrase, err = gopass.GetPasswd()
|
passphrase, err = term.ReadPassword(int(syscall.Stdin))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("couldn't read passphrase: %v", err)
|
return nil, fmt.Errorf("couldn't read passphrase: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user