summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/ssh.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2001-03-08 21:42:31 +0000
committermarkus <markus@openbsd.org>2001-03-08 21:42:31 +0000
commitd2f8a85cc9c7d3a223284c8707611f7a8996f4e3 (patch)
treebf7ff354d045ae07a0021cf5246ed78731301c4f /usr.bin/ssh/ssh.c
parentwhack exit(-#) (diff)
downloadwireguard-openbsd-d2f8a85cc9c7d3a223284c8707611f7a8996f4e3.tar.xz
wireguard-openbsd-d2f8a85cc9c7d3a223284c8707611f7a8996f4e3.zip
implement client side of SSH2_MSG_USERAUTH_PK_OK (test public key ->
no need to do enter passphrase or do expensive sign operations if the server does not accept key).
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r--usr.bin/ssh/ssh.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 6c2a64ff6c5..728830b3ca4 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.103 2001/03/04 17:42:28 millert Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.104 2001/03/08 21:42:32 markus Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -225,7 +225,7 @@ rsh_connect(char *host, char *user, Buffer * command)
int ssh_session(void);
int ssh_session2(void);
-int guess_identity_file_type(const char *filename);
+void load_public_identity_files(void);
/*
* Main program for the ssh client.
@@ -660,15 +660,11 @@ main(int ac, char **av)
}
exit(1);
}
- /* Expand ~ in options.identity_files, known host file names. */
- /* XXX mem-leaks */
- for (i = 0; i < options.num_identity_files; i++) {
- options.identity_files[i] =
- tilde_expand_filename(options.identity_files[i], original_real_uid);
- options.identity_files_type[i] = guess_identity_file_type(options.identity_files[i]);
- debug("identity file %s type %d", options.identity_files[i],
- options.identity_files_type[i]);
- }
+ /* load options.identity_files */
+ load_public_identity_files();
+
+ /* Expand ~ in known host file names. */
+ /* XXX mem-leaks: */
options.system_hostfile =
tilde_expand_filename(options.system_hostfile, original_real_uid);
options.user_hostfile =
@@ -1077,3 +1073,31 @@ guess_identity_file_type(const char *filename)
key_free(public);
return type;
}
+
+void
+load_public_identity_files(void)
+{
+ char *filename;
+ Key *public;
+ int i;
+
+ for (i = 0; i < options.num_identity_files; i++) {
+ filename = tilde_expand_filename(options.identity_files[i],
+ original_real_uid);
+ public = key_new(KEY_RSA1);
+ if (!load_public_key(filename, public, NULL)) {
+ key_free(public);
+ public = key_new(KEY_UNSPEC);
+ if (!try_load_public_key(filename, public, NULL)) {
+ debug("unknown identity file %s", filename);
+ key_free(public);
+ public = NULL;
+ }
+ }
+ debug("identity file %s type %d", filename,
+ public ? public->type : -1);
+ xfree(options.identity_files[i]);
+ options.identity_files[i] = filename;
+ options.identity_keys[i] = public;
+ }
+}