aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/puppeth/ssh.go
diff options
context:
space:
mode:
authorYondon Fu <yondon.fu@gmail.com>2017-12-19 06:17:41 +0800
committerYondon Fu <yondon.fu@gmail.com>2017-12-19 06:17:41 +0800
commit3857cdc267e3192697f561df0a0f827f65dfb6b5 (patch)
tree401c52c4972a68229ea283a394a0b0a5f3cfdc8e /cmd/puppeth/ssh.go
parenta5330fe0c569b75cb8a524f60f7e8dc06498262b (diff)
parentfe070ab5c32702033489f1b9d1655ea1b894c29e (diff)
downloaddexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.gz
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.bz2
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.lz
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.xz
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.zst
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.zip
Merge branch 'master' into abi-offset-fixed-arrays
Diffstat (limited to 'cmd/puppeth/ssh.go')
-rw-r--r--cmd/puppeth/ssh.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/cmd/puppeth/ssh.go b/cmd/puppeth/ssh.go
index 26f846685..158261ce0 100644
--- a/cmd/puppeth/ssh.go
+++ b/cmd/puppeth/ssh.go
@@ -27,7 +27,6 @@ import (
"os/user"
"path/filepath"
"strings"
- "syscall"
"github.com/ethereum/go-ethereum/log"
"golang.org/x/crypto/ssh"
@@ -78,14 +77,25 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
} else {
key, err := ssh.ParsePrivateKey(buf)
if err != nil {
- log.Warn("Bad SSH key, falling back to passwords", "path", path, "err", err)
+ fmt.Printf("What's the decryption password for %s? (won't be echoed)\n>", path)
+ blob, err := terminal.ReadPassword(int(os.Stdin.Fd()))
+ fmt.Println()
+ if err != nil {
+ log.Warn("Couldn't read password", "err", err)
+ }
+ key, err := ssh.ParsePrivateKeyWithPassphrase(buf, blob)
+ if err != nil {
+ log.Warn("Failed to decrypt SSH key, falling back to passwords", "path", path, "err", err)
+ } else {
+ auths = append(auths, ssh.PublicKeys(key))
+ }
} else {
auths = append(auths, ssh.PublicKeys(key))
}
}
auths = append(auths, ssh.PasswordCallback(func() (string, error) {
fmt.Printf("What's the login password for %s at %s? (won't be echoed)\n> ", login, server)
- blob, err := terminal.ReadPassword(int(syscall.Stdin))
+ blob, err := terminal.ReadPassword(int(os.Stdin.Fd()))
fmt.Println()
return string(blob), err
@@ -106,6 +116,7 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
keycheck := func(hostname string, remote net.Addr, key ssh.PublicKey) error {
// If no public key is known for SSH, ask the user to confirm
if pubkey == nil {
+ fmt.Println()
fmt.Printf("The authenticity of host '%s (%s)' can't be established.\n", hostname, remote)
fmt.Printf("SSH key fingerprint is %s [MD5]\n", ssh.FingerprintLegacyMD5(key))
fmt.Printf("Are you sure you want to continue connecting (yes/no)? ")
@@ -205,8 +216,8 @@ func (client *sshClient) Stream(cmd string) error {
return session.Run(cmd)
}
-// Upload copied the set of files to a remote server via SCP, creating any non-
-// existing folder in te mean time.
+// Upload copies the set of files to a remote server via SCP, creating any non-
+// existing folders in the mean time.
func (client *sshClient) Upload(files map[string][]byte) ([]byte, error) {
// Establish a single command session
session, err := client.client.NewSession()