Skip to content

Commit f56f969

Browse files
authored
Merge pull request #20350 from holiman/puppeth_ssh
cmd/puppeth: make ssh prompt more user-friendly
2 parents 7be89a7 + 216ff5a commit f56f969

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

‎cmd/puppeth/ssh.go‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,20 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
129129
fmt.Printf("SSH key fingerprint is %s [MD5]\n", ssh.FingerprintLegacyMD5(key))
130130
fmt.Printf("Are you sure you want to continue connecting (yes/no)? ")
131131

132-
text, err := bufio.NewReader(os.Stdin).ReadString('\n')
133-
switch {
134-
case err != nil:
135-
return err
136-
case strings.TrimSpace(text) == "yes":
137-
pubkey = key.Marshal()
138-
return nil
139-
default:
140-
return fmt.Errorf("unknown auth choice: %v", text)
132+
for {
133+
text, err := bufio.NewReader(os.Stdin).ReadString('\n')
134+
switch {
135+
case err != nil:
136+
return err
137+
case strings.TrimSpace(text) == "yes":
138+
pubkey = key.Marshal()
139+
return nil
140+
case strings.TrimSpace(text) == "no":
141+
return errors.New("users says no")
142+
default:
143+
fmt.Println("Please answer 'yes' or 'no'")
144+
continue
145+
}
141146
}
142147
}
143148
// If a public key exists for this SSH server, check that it matches

0 commit comments

Comments
 (0)