|
Lines 608-618
check_host_key(char *host, struct sockad
Link Here
|
| 608 |
* hosts or in the systemwide list. |
608 |
* hosts or in the systemwide list. |
| 609 |
*/ |
609 |
*/ |
| 610 |
host_file = user_hostfile; |
610 |
host_file = user_hostfile; |
| 611 |
host_status = check_host_in_hostfile(host_file, host, host_key, |
611 |
host_status = check_host_in_hostfile(host_file, host, options.port, host_key, |
| 612 |
file_key, &host_line); |
612 |
file_key, &host_line); |
| 613 |
if (host_status == HOST_NEW) { |
613 |
if (host_status == HOST_NEW) { |
| 614 |
host_file = system_hostfile; |
614 |
host_file = system_hostfile; |
| 615 |
host_status = check_host_in_hostfile(host_file, host, host_key, |
615 |
host_status = check_host_in_hostfile(host_file, host, options.port, host_key, |
| 616 |
file_key, &host_line); |
616 |
file_key, &host_line); |
| 617 |
} |
617 |
} |
| 618 |
/* |
618 |
/* |
|
Lines 623-633
check_host_key(char *host, struct sockad
Link Here
|
| 623 |
Key *ip_key = key_new(host_key->type); |
623 |
Key *ip_key = key_new(host_key->type); |
| 624 |
|
624 |
|
| 625 |
ip_file = user_hostfile; |
625 |
ip_file = user_hostfile; |
| 626 |
ip_status = check_host_in_hostfile(ip_file, ip, host_key, |
626 |
ip_status = check_host_in_hostfile(ip_file, ip, options.port, host_key, |
| 627 |
ip_key, &ip_line); |
627 |
ip_key, &ip_line); |
| 628 |
if (ip_status == HOST_NEW) { |
628 |
if (ip_status == HOST_NEW) { |
| 629 |
ip_file = system_hostfile; |
629 |
ip_file = system_hostfile; |
| 630 |
ip_status = check_host_in_hostfile(ip_file, ip, |
630 |
ip_status = check_host_in_hostfile(ip_file, ip, options.port, |
| 631 |
host_key, ip_key, &ip_line); |
631 |
host_key, ip_key, &ip_line); |
| 632 |
} |
632 |
} |
| 633 |
if (host_status == HOST_CHANGED && |
633 |
if (host_status == HOST_CHANGED && |
|
Lines 651-665
check_host_key(char *host, struct sockad
Link Here
|
| 651 |
logit("%s host key for IP address " |
651 |
logit("%s host key for IP address " |
| 652 |
"'%.128s' not in list of known hosts.", |
652 |
"'%.128s' not in list of known hosts.", |
| 653 |
type, ip); |
653 |
type, ip); |
| 654 |
else if (!add_host_to_hostfile(user_hostfile, ip, |
654 |
else if (!add_host_to_hostfile(user_hostfile, ip, options.port, |
| 655 |
host_key, options.hash_known_hosts)) |
655 |
host_key, options.hash_known_hosts)) |
| 656 |
logit("Failed to add the %s host key for IP " |
656 |
logit("Failed to add the %s host key for IP " |
| 657 |
"address '%.128s' to the list of known " |
657 |
"address '%.128s:%hu' to the list of known " |
| 658 |
"hosts (%.30s).", type, ip, user_hostfile); |
658 |
"hosts (%.30s).", type, ip, options.port, user_hostfile); |
| 659 |
else |
659 |
else |
| 660 |
logit("Warning: Permanently added the %s host " |
660 |
logit("Warning: Permanently added the %s host " |
| 661 |
"key for IP address '%.128s' to the list " |
661 |
"key for IP address '%.128s:%hu' to the list " |
| 662 |
"of known hosts.", type, ip); |
662 |
"of known hosts.", type, ip, options.port); |
| 663 |
} |
663 |
} |
| 664 |
break; |
664 |
break; |
| 665 |
case HOST_NEW: |
665 |
case HOST_NEW: |
|
Lines 718-735
check_host_key(char *host, struct sockad
Link Here
|
| 718 |
hostp = hostline; |
718 |
hostp = hostline; |
| 719 |
if (options.hash_known_hosts) { |
719 |
if (options.hash_known_hosts) { |
| 720 |
/* Add hash of host and IP separately */ |
720 |
/* Add hash of host and IP separately */ |
| 721 |
r = add_host_to_hostfile(user_hostfile, host, |
721 |
r = add_host_to_hostfile(user_hostfile, host, options.port, |
| 722 |
host_key, options.hash_known_hosts) && |
722 |
host_key, options.hash_known_hosts) && |
| 723 |
add_host_to_hostfile(user_hostfile, ip, |
723 |
add_host_to_hostfile(user_hostfile, ip, options.port, |
| 724 |
host_key, options.hash_known_hosts); |
724 |
host_key, options.hash_known_hosts); |
| 725 |
} else { |
725 |
} else { |
| 726 |
/* Add unhashed "host,ip" */ |
726 |
/* Add unhashed "host,ip" */ |
| 727 |
r = add_host_to_hostfile(user_hostfile, |
727 |
r = add_host_to_hostfile(user_hostfile, |
| 728 |
hostline, host_key, |
728 |
hostline, options.port, host_key, |
| 729 |
options.hash_known_hosts); |
729 |
options.hash_known_hosts); |
| 730 |
} |
730 |
} |
| 731 |
} else { |
731 |
} else { |
| 732 |
r = add_host_to_hostfile(user_hostfile, host, host_key, |
732 |
r = add_host_to_hostfile(user_hostfile, host, options.port, host_key, |
| 733 |
options.hash_known_hosts); |
733 |
options.hash_known_hosts); |
| 734 |
hostp = host; |
734 |
hostp = host; |
| 735 |
} |
735 |
} |
|
Lines 738-745
check_host_key(char *host, struct sockad
Link Here
|
| 738 |
logit("Failed to add the host to the list of known " |
738 |
logit("Failed to add the host to the list of known " |
| 739 |
"hosts (%.500s).", user_hostfile); |
739 |
"hosts (%.500s).", user_hostfile); |
| 740 |
else |
740 |
else |
| 741 |
logit("Warning: Permanently added '%.200s' (%s) to the " |
741 |
logit("Warning: Permanently added '%.200s:%hu' (%s) to the " |
| 742 |
"list of known hosts.", hostp, type); |
742 |
"list of known hosts.", hostp, options.port, type); |
| 743 |
break; |
743 |
break; |
| 744 |
case HOST_CHANGED: |
744 |
case HOST_CHANGED: |
| 745 |
if (options.check_host_ip && host_ip_differ) { |
745 |
if (options.check_host_ip && host_ip_differ) { |
|
Lines 961-974
ssh_put_password(char *password)
Link Here
|
| 961 |
} |
961 |
} |
| 962 |
|
962 |
|
| 963 |
static int |
963 |
static int |
| 964 |
show_key_from_file(const char *file, const char *host, int keytype) |
964 |
show_key_from_file(const char *file, const char *host, u_short port, int keytype) |
| 965 |
{ |
965 |
{ |
| 966 |
Key *found; |
966 |
Key *found; |
| 967 |
char *fp; |
967 |
char *fp; |
| 968 |
int line, ret; |
968 |
int line, ret; |
| 969 |
|
969 |
|
| 970 |
found = key_new(keytype); |
970 |
found = key_new(keytype); |
| 971 |
if ((ret = lookup_key_in_hostfile_by_type(file, host, |
971 |
if ((ret = lookup_key_in_hostfile_by_type(file, host, port, |
| 972 |
keytype, found, &line))) { |
972 |
keytype, found, &line))) { |
| 973 |
fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX); |
973 |
fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX); |
| 974 |
logit("WARNING: %s key found for host %s\n" |
974 |
logit("WARNING: %s key found for host %s\n" |
|
Lines 993-1012
show_other_keys(const char *host, Key *k
Link Here
|
| 993 |
if (type[i] == key->type) |
993 |
if (type[i] == key->type) |
| 994 |
continue; |
994 |
continue; |
| 995 |
if (type[i] != KEY_RSA1 && |
995 |
if (type[i] != KEY_RSA1 && |
| 996 |
show_key_from_file(options.user_hostfile2, host, type[i])) { |
996 |
show_key_from_file(options.user_hostfile2, host, options.port, type[i])) { |
| 997 |
found = 1; |
997 |
found = 1; |
| 998 |
continue; |
998 |
continue; |
| 999 |
} |
999 |
} |
| 1000 |
if (type[i] != KEY_RSA1 && |
1000 |
if (type[i] != KEY_RSA1 && |
| 1001 |
show_key_from_file(options.system_hostfile2, host, type[i])) { |
1001 |
show_key_from_file(options.system_hostfile2, host, options.port, type[i])) { |
| 1002 |
found = 1; |
1002 |
found = 1; |
| 1003 |
continue; |
1003 |
continue; |
| 1004 |
} |
1004 |
} |
| 1005 |
if (show_key_from_file(options.user_hostfile, host, type[i])) { |
1005 |
if (show_key_from_file(options.user_hostfile, host, options.port, type[i])) { |
| 1006 |
found = 1; |
1006 |
found = 1; |
| 1007 |
continue; |
1007 |
continue; |
| 1008 |
} |
1008 |
} |
| 1009 |
if (show_key_from_file(options.system_hostfile, host, type[i])) { |
1009 |
if (show_key_from_file(options.system_hostfile, host, options.port, type[i])) { |
| 1010 |
found = 1; |
1010 |
found = 1; |
| 1011 |
continue; |
1011 |
continue; |
| 1012 |
} |
1012 |
} |