X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=ssh.c;h=c9b1bcdb938a9c4f9c9d015bd4997904fd13cfeb;hb=3b20d71a7ee9b8efa00bba86ea16dc52be4dd3ff;hp=c05abe28f7e42233b59cf35da17b22c241b31f28;hpb=17af65c78c2e754647f37cf0599b6bced213d7c6;p=PuTTY.git diff --git a/ssh.c b/ssh.c index c05abe28..c9b1bcdb 100644 --- a/ssh.c +++ b/ssh.c @@ -1722,6 +1722,12 @@ static int do_ssh_init(unsigned char c) sprintf(vlog, "We claim version: %s", verstring); logevent(vlog); strcat(verstring, "\n"); + + if (cfg.sshprot == 3) { + bombout(("SSH protocol version 2 required by user but not provided by server")); + crReturn(0); + } + logevent("Using SSH protocol version 1"); sk_write(s, verstring, strlen(verstring)); ssh_protocol = ssh1_protocol; @@ -2430,8 +2436,22 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt) } if (pwpkt_type == SSH1_CMSG_AUTH_RSA) { char *comment = NULL; + int type; + char msgbuf[256]; if (flags & FLAG_VERBOSE) c_write_str("Trying public key authentication.\r\n"); + sprintf(msgbuf, "Trying public key \"%.200s\"", cfg.keyfile); + logevent(msgbuf); + type = key_type(cfg.keyfile); + if (type != SSH_KEYTYPE_SSH1) { + sprintf(msgbuf, "Key is of wrong type (%s)", + key_type_to_str(type)); + logevent(msgbuf); + c_write_str(msgbuf); + c_write_str("\r\n"); + tried_publickey = 1; + continue; + } if (!rsakey_encrypted(cfg.keyfile, &comment)) { if (flags & FLAG_VERBOSE) c_write_str("No passphrase required.\r\n"); @@ -4085,8 +4105,21 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) kbd_inter_running = FALSE; /* Load the pub half of cfg.keyfile so we notice if it's in Pageant */ if (*cfg.keyfile) { - publickey_blob = ssh2_userkey_loadpub(cfg.keyfile, NULL, - &publickey_bloblen); + int keytype; + logeventf("Reading private key file \"%.150s\"", cfg.keyfile); + keytype = key_type(cfg.keyfile); + if (keytype == SSH_KEYTYPE_SSH2) + publickey_blob = ssh2_userkey_loadpub(cfg.keyfile, NULL, + &publickey_bloblen); + else { + char msgbuf[256]; + logeventf("Unable to use this key file (%s)", + key_type_to_str(keytype)); + sprintf(msgbuf, "Unable to use key file \"%.150s\" (%s)\r\n", + cfg.keyfile, key_type_to_str(keytype)); + c_write_str(msgbuf); + publickey_blob = NULL; + } } else publickey_blob = NULL; @@ -4345,7 +4378,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) } } - if (!method && can_pubkey && *cfg.keyfile + if (!method && can_pubkey && publickey_blob && !tried_pubkey_config) { unsigned char *pub_blob; char *algorithm, *comment;