diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-05-21 11:41:44 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-06-08 15:25:18 +0800 |
commit | 9ceadd480c24d61148c120335931456b39a4837b (patch) | |
tree | 59f1595ccc27e618819c471d2726a37ad452e588 /src/protocol/fqterm_ssh_socket.cpp | |
parent | 083414da945ff6e4be429a43b3e5cfefe10e7c05 (diff) | |
download | fqterm-9ceadd480c24d61148c120335931456b39a4837b.tar.xz |
conn_info: show if host key matches
Diffstat (limited to 'src/protocol/fqterm_ssh_socket.cpp')
-rw-r--r-- | src/protocol/fqterm_ssh_socket.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/protocol/fqterm_ssh_socket.cpp b/src/protocol/fqterm_ssh_socket.cpp index d6c2e61..8649bb9 100644 --- a/src/protocol/fqterm_ssh_socket.cpp +++ b/src/protocol/fqterm_ssh_socket.cpp @@ -28,6 +28,8 @@ #include "fqterm_ssh_auth.h" #include "fqterm_ssh_channel.h" #include "fqterm_trace.h" +#include "fqterm_path.h" +#include "ssh_known_hosts.h" #include <QString> namespace FQTerm { @@ -144,6 +146,25 @@ void FQTermSSHSocket::kexOK() conn_info.ssh_proto_info.c2s_mac = packet_sender_->mac->name; if (packet_receiver_->mac) conn_info.ssh_proto_info.s2c_mac = packet_receiver_->mac->name; + + if (ssh_version_ == 2) { + int nhosts; + struct ssh_host *hosts; + const char *hosts_file; +#ifdef WIN32 + hosts_file = (getPath(USER_CONFIG) + "known_hosts").toLatin1().constData(); +#else + hosts_file = ssh_hosts_filename(); +#endif + hosts = parse_hosts_file(hosts_file, &nhosts); + int idx = find_ssh_host(hosts, nhosts, conn_info.hostname, conn_info.port); + FQTermSSH2Kex *kex = dynamic_cast<FQTermSSH2Kex *> (key_exchanger_); + if (idx >=0 && key_matches(&hosts[idx], kex->K_S(), kex->K_S_len())) + conn_info.ssh_proto_info.key_matches = 1; + else + conn_info.ssh_proto_info.key_matches = 0; + } + key_exchanger_->hostKeyHash(conn_info.ssh_proto_info.hash); authentication_->initAuth(packet_receiver_, packet_sender_); } |