|
Lines 701-706
confirm(const char *prompt)
Link Here
|
| 701 |
} |
701 |
} |
| 702 |
|
702 |
|
| 703 |
static int |
703 |
static int |
|
|
704 |
confirm_fingerprint(const char *prompt, const char *fp) |
| 705 |
{ |
| 706 |
char *p; |
| 707 |
int ret = 0; |
| 708 |
|
| 709 |
if (options.batch_mode) |
| 710 |
return 0; |
| 711 |
|
| 712 |
p = read_passphrase(prompt, RP_ECHO); |
| 713 |
if (p != NULL && strncmp(p, fp, strlen(fp)) == 0) { |
| 714 |
ret = 1; |
| 715 |
free(p); |
| 716 |
} |
| 717 |
return ret; |
| 718 |
} |
| 719 |
|
| 720 |
static int |
| 704 |
check_host_cert(const char *host, const Key *host_key) |
721 |
check_host_cert(const char *host, const Key *host_key) |
| 705 |
{ |
722 |
{ |
| 706 |
const char *reason; |
723 |
const char *reason; |
|
Lines 947-953
check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
Link Here
|
| 947 |
error("No %s host key is known for %.200s and you " |
964 |
error("No %s host key is known for %.200s and you " |
| 948 |
"have requested strict checking.", type, host); |
965 |
"have requested strict checking.", type, host); |
| 949 |
goto fail; |
966 |
goto fail; |
| 950 |
} else if (options.strict_host_key_checking == 2) { |
967 |
} else if (options.strict_host_key_checking == 2 || options.strict_host_key_checking == 3) { |
| 951 |
char msg1[1024], msg2[1024]; |
968 |
char msg1[1024], msg2[1024]; |
| 952 |
|
969 |
|
| 953 |
if (show_other_keys(host_hostkeys, host_key)) |
970 |
if (show_other_keys(host_hostkeys, host_key)) |
|
Lines 972-992
check_host_key(char *hostname, struct sockaddr *hostaddr, u_short port,
Link Here
|
| 972 |
"No matching host key fingerprint" |
989 |
"No matching host key fingerprint" |
| 973 |
" found in DNS.\n"); |
990 |
" found in DNS.\n"); |
| 974 |
} |
991 |
} |
| 975 |
snprintf(msg, sizeof(msg), |
992 |
if (options.strict_host_key_checking == 2) { |
| 976 |
"The authenticity of host '%.200s (%s)' can't be " |
993 |
snprintf(msg, sizeof(msg), |
| 977 |
"established%s\n" |
994 |
"The authenticity of host '%.200s (%s)' can't be " |
| 978 |
"%s key fingerprint is [%s]%s.%s%s\n%s" |
995 |
"established%s\n" |
| 979 |
"Are you sure you want to continue connecting " |
996 |
"%s key fingerprint is [%s]%s.%s%s\n%s" |
| 980 |
"(yes/no)? ", |
997 |
"Are you sure you want to continue connecting " |
| 981 |
host, ip, msg1, type, fpt, fp, |
998 |
"(yes/no)? ", |
| 982 |
options.visual_host_key ? "\n" : "", |
999 |
host, ip, msg1, type, fpt, fp, |
| 983 |
options.visual_host_key ? ra : "", |
1000 |
options.visual_host_key ? "\n" : "", |
| 984 |
msg2); |
1001 |
options.visual_host_key ? ra : "", |
| 985 |
free(ra); |
1002 |
msg2); |
| 986 |
free(fpt); |
1003 |
free(ra); |
| 987 |
free(fp); |
1004 |
free(fpt); |
| 988 |
if (!confirm(msg)) |
1005 |
free(fp); |
| 989 |
goto fail; |
1006 |
if (!confirm(msg)) |
|
|
1007 |
goto fail; |
| 1008 |
} else { |
| 1009 |
snprintf(msg, sizeof(msg), |
| 1010 |
"The authenticity of host '%.200s (%s)' can't be " |
| 1011 |
"established%s\n" |
| 1012 |
"Type the %s key fingerprint from remote host [%s]: ", |
| 1013 |
host, ip, msg1, type, fpt); |
| 1014 |
free(ra); |
| 1015 |
free(fpt); |
| 1016 |
if (!confirm_fingerprint(msg, fp)) { |
| 1017 |
free(fp); |
| 1018 |
goto fail; |
| 1019 |
} |
| 1020 |
free(fp); |
| 1021 |
} |
| 990 |
} |
1022 |
} |
| 991 |
/* |
1023 |
/* |
| 992 |
* If not in strict mode, add the key automatically to the |
1024 |
* If not in strict mode, add the key automatically to the |
| 993 |
- |
|
|