summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-04-23 21:57:08 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-04-23 21:57:08 +0000
commit8894abbe6e18a27ed2781157658f5015a3183fc0 (patch)
tree7fce44e55922e8afa76e6d2997281df2313a0b4a /usr.bin
parent46fb4dd5de5f3e4e906436c2607ba18bbbd04e2b (diff)
allow public key for -e, too
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-keygen.15
-rw-r--r--usr.bin/ssh/ssh-keygen.c19
2 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/ssh/ssh-keygen.1 b/usr.bin/ssh/ssh-keygen.1
index 613bc95d72a..371fc5fe471 100644
--- a/usr.bin/ssh/ssh-keygen.1
+++ b/usr.bin/ssh/ssh-keygen.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ssh-keygen.1,v 1.39 2001/04/22 23:58:36 markus Exp $
+.\" $OpenBSD: ssh-keygen.1,v 1.40 2001/04/23 21:57:07 markus Exp $
.\"
.\" -*- nroff -*-
.\"
@@ -145,7 +145,8 @@ Requests changing the comment in the private and public key files.
The program will prompt for the file containing the private keys, for
passphrase if the key has one, and for the new comment.
.It Fl e
-This option will read a private OpenSSH key file and print the key in a
+This option will read a private or public OpenSSH key file and
+print the key in a
.Sq SECSH Public Key File Format
to stdout.
This option allows exporting keys for use by several commercial
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index 60d9edb4022..c2d0f9ad965 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.58 2001/04/22 13:41:02 markus Exp $");
+RCSID("$OpenBSD: ssh-keygen.c,v 1.59 2001/04/23 21:57:07 markus Exp $");
#include <openssl/evp.h>
#include <openssl/pem.h>
@@ -132,7 +132,7 @@ try_load_pem_key(char *filename)
void
do_convert_to_ssh2(struct passwd *pw)
{
- Key *prv;
+ Key *k;
int len;
u_char *blob;
struct stat st;
@@ -143,20 +143,21 @@ do_convert_to_ssh2(struct passwd *pw)
perror(identity_file);
exit(1);
}
- prv = try_load_pem_key(identity_file);
- if (prv == NULL) {
- fprintf(stderr, "load failed\n");
- exit(1);
+ if ((k = key_load_public(identity_file, NULL)) == NULL) {
+ if ((k = try_load_pem_key(identity_file)) == NULL) {
+ fprintf(stderr, "load failed\n");
+ exit(1);
+ }
}
- key_to_blob(prv, &blob, &len);
+ key_to_blob(k, &blob, &len);
fprintf(stdout, "%s\n", SSH_COM_PUBLIC_BEGIN);
fprintf(stdout,
"Comment: \"%d-bit %s, converted from OpenSSH by %s@%s\"\n",
- key_size(prv), key_type(prv),
+ key_size(k), key_type(k),
pw->pw_name, hostname);
dump_base64(stdout, blob, len);
fprintf(stdout, "%s\n", SSH_COM_PUBLIC_END);
- key_free(prv);
+ key_free(k);
xfree(blob);
exit(0);
}