[ssh-keygen.1 ssh-keygen.c]
     allow public key for -e, too
This commit is contained in:
Ben Lindstrom 2001-04-24 16:56:58 +00:00
parent 4adb091c29
commit 46c264f2ae
3 changed files with 20 additions and 12 deletions

View File

@ -1,3 +1,9 @@
20010425
- OpenBSD CVS Sync
- markus@cvs.openbsd.org 2001/04/23 21:57:07
[ssh-keygen.1 ssh-keygen.c]
allow public key for -e, too
20010424
- OpenBSD CVS Sync
- markus@cvs.openbsd.org 2001/04/22 23:58:36
@ -5236,4 +5242,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
$Id: ChangeLog,v 1.1165 2001/04/24 00:03:58 mouring Exp $
$Id: ChangeLog,v 1.1166 2001/04/24 16:56:58 mouring Exp $

View File

@ -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

View File

@ -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>
@ -136,7 +136,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;
@ -147,20 +147,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);
}