Skip to content

Commit

Permalink
cmd/puppeth: make ssh prompt more user-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman authored and enriquefynn committed Feb 15, 2021
1 parent ffdb6f0 commit fa0c9a0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions cmd/puppeth/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("Are you sure you want to continue connecting (yes/no)? ")

text, err := bufio.NewReader(os.Stdin).ReadString('\n')
switch {
case err != nil:
return err
case strings.TrimSpace(text) == "yes":
pubkey = key.Marshal()
return nil
default:
return fmt.Errorf("unknown auth choice: %v", text)
for {
text, err := bufio.NewReader(os.Stdin).ReadString('\n')
switch {
case err != nil:
return err
case strings.TrimSpace(text) == "yes":
pubkey = key.Marshal()
return nil
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
Expand Down

0 comments on commit fa0c9a0

Please sign in to comment.