cmd/puppeth: make ssh prompt more user-friendly
This commit is contained in:
		| @@ -129,6 +129,7 @@ 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)? ") | ||||||
|  |  | ||||||
|  | 			for { | ||||||
| 				text, err := bufio.NewReader(os.Stdin).ReadString('\n') | 				text, err := bufio.NewReader(os.Stdin).ReadString('\n') | ||||||
| 				switch { | 				switch { | ||||||
| 				case err != nil: | 				case err != nil: | ||||||
| @@ -136,8 +137,12 @@ func dial(server string, pubkey []byte) (*sshClient, error) { | |||||||
| 				case strings.TrimSpace(text) == "yes": | 				case strings.TrimSpace(text) == "yes": | ||||||
| 					pubkey = key.Marshal() | 					pubkey = key.Marshal() | ||||||
| 					return nil | 					return nil | ||||||
|  | 				case strings.TrimSpace(text) == "no": | ||||||
|  | 					return errors.New("users says no") | ||||||
| 				default: | 				default: | ||||||
| 				return fmt.Errorf("unknown auth choice: %v", text) | 					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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user