diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2000-11-25 17:19:34 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2000-11-25 17:19:34 +0000 |
commit | ab457a8b954c202b9fa6114b6d20bdeda5bc50c2 (patch) | |
tree | abb555e119400acbb074972bac8dc3523ba5afa1 /usr.bin | |
parent | ebc1e85233fbc05976bc7c65b929dd5b42125279 (diff) |
print keytype when generating a key.
reasonable defaults for RSA1/RSA/DSA keys.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/ssh-keygen.c | 45 | ||||
-rw-r--r-- | usr.bin/ssh/ssh.h | 3 |
2 files changed, 29 insertions, 19 deletions
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c index 05c4f70bfaf..bfa68e428f3 100644 --- a/usr.bin/ssh/ssh-keygen.c +++ b/usr.bin/ssh/ssh-keygen.c @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keygen.c,v 1.34 2000/11/15 20:24:43 millert Exp $"); +RCSID("$OpenBSD: ssh-keygen.c,v 1.35 2000/11/25 17:19:33 markus Exp $"); #include <openssl/evp.h> #include <openssl/pem.h> @@ -67,9 +67,8 @@ int convert_to_ssh2 = 0; int convert_from_ssh2 = 0; int print_public = 0; -/* key type */ -int dsa_mode = 0; /* compat */ -char *key_type_name = NULL; +/* default to RSA for SSH-1 */ +char *key_type_name = "rsa1"; /* argv0 */ extern char *__progname; @@ -80,9 +79,24 @@ void ask_filename(struct passwd *pw, const char *prompt) { char buf[1024]; - snprintf(identity_file, sizeof(identity_file), "%s/%s", - pw->pw_dir, - dsa_mode ? SSH_CLIENT_ID_DSA: SSH_CLIENT_IDENTITY); + char *name = NULL; + + switch (key_type_from_name(key_type_name)) { + case KEY_RSA1: + name = SSH_CLIENT_IDENTITY; + break; + case KEY_DSA: + name = SSH_CLIENT_ID_DSA; + break; + case KEY_RSA: + name = SSH_CLIENT_ID_RSA; + break; + default: + fprintf(stderr, "bad key type"); + exit(1); + break; + } + snprintf(identity_file, sizeof(identity_file), "%s/%s", pw->pw_dir, name); printf("%s (%s): ", prompt, identity_file); fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) @@ -596,10 +610,9 @@ main(int ac, char **av) { char dotsshdir[16 * 1024], comment[1024], *passphrase1, *passphrase2; struct passwd *pw; - int opt; + int opt, type; struct stat st; FILE *f; - int type = KEY_RSA1; Key *private; Key *public; @@ -681,12 +694,10 @@ main(int ac, char **av) case 'd': key_type_name = "dsa"; - dsa_mode = 1; break; case 't': key_type_name = optarg; - dsa_mode = (strcmp(optarg, "dsa") == 0); break; case '?': @@ -717,15 +728,13 @@ main(int ac, char **av) arc4random_stir(); - if (key_type_name != NULL) { - type = key_type_from_name(key_type_name); - if (type == KEY_UNSPEC) { - fprintf(stderr, "unknown key type %s\n", key_type_name); - exit(1); - } + type = key_type_from_name(key_type_name); + if (type == KEY_UNSPEC) { + fprintf(stderr, "unknown key type %s\n", key_type_name); + exit(1); } if (!quiet) - printf("Generating public/private key pair.\n"); + printf("Generating public/private %s key pair.\n", key_type_name); private = key_generate(type, bits); if (private == NULL) { fprintf(stderr, "key_generate failed"); diff --git a/usr.bin/ssh/ssh.h b/usr.bin/ssh/ssh.h index f8c58e6051c..67df3d43208 100644 --- a/usr.bin/ssh/ssh.h +++ b/usr.bin/ssh/ssh.h @@ -12,7 +12,7 @@ * called by a name other than "ssh" or "Secure Shell". */ -/* RCSID("$OpenBSD: ssh.h,v 1.54 2000/10/11 20:27:24 markus Exp $"); */ +/* RCSID("$OpenBSD: ssh.h,v 1.55 2000/11/25 17:19:33 markus Exp $"); */ #ifndef SSH_H #define SSH_H @@ -103,6 +103,7 @@ */ #define SSH_CLIENT_IDENTITY ".ssh/identity" #define SSH_CLIENT_ID_DSA ".ssh/id_dsa" +#define SSH_CLIENT_ID_RSA ".ssh/id_rsa" /* * Configuration file in user\'s home directory. This file need not be |