forked from cerc-io/plugeth
cmd/puppeth: make ssh prompt more user-friendly
This commit is contained in:
parent
c5b46a79c1
commit
216ff5a952
@ -129,15 +129,20 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
|
|||||||
fmt.Printf("SSH key fingerprint is %s [MD5]\n", ssh.FingerprintLegacyMD5(key))
|
fmt.Printf("SSH key fingerprint is %s [MD5]\n", ssh.FingerprintLegacyMD5(key))
|
||||||
fmt.Printf("Are you sure you want to continue connecting (yes/no)? ")
|
fmt.Printf("Are you sure you want to continue connecting (yes/no)? ")
|
||||||
|
|
||||||
text, err := bufio.NewReader(os.Stdin).ReadString('\n')
|
for {
|
||||||
switch {
|
text, err := bufio.NewReader(os.Stdin).ReadString('\n')
|
||||||
case err != nil:
|
switch {
|
||||||
return err
|
case err != nil:
|
||||||
case strings.TrimSpace(text) == "yes":
|
return err
|
||||||
pubkey = key.Marshal()
|
case strings.TrimSpace(text) == "yes":
|
||||||
return nil
|
pubkey = key.Marshal()
|
||||||
default:
|
return nil
|
||||||
return fmt.Errorf("unknown auth choice: %v", text)
|
case strings.TrimSpace(text) == "no":
|
||||||
|
return errors.New("users says no")
|
||||||
|
default:
|
||||||
|
fmt.Println("Please answer 'yes' or 'no'")
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If a public key exists for this SSH server, check that it matches
|
// If a public key exists for this SSH server, check that it matches
|
||||||
|
Loading…
Reference in New Issue
Block a user