summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-keygen.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-05-19 15:46:32 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-05-19 15:46:32 +0000
commit814839722b5de3be005fb62030e5e2a3f816e6b7 (patch)
tree684c86b2572d92910ce9dcf21197579d95912463 /usr.bin/ssh/ssh-keygen.c
parent598ef7150f30391faa91b0547abd92cfe1f53987 (diff)
support -l (print fingerprint) in combination with -F (find host) to
search for a host in ~/.ssh/known_hosts and display its fingerprint; ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh-keygen.c')
-rw-r--r--usr.bin/ssh/ssh-keygen.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index bd5a262cd88..5fcb13f0c03 100644
--- a/usr.bin/ssh/ssh-keygen.c
+++ b/usr.bin/ssh/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.165 2008/01/19 22:37:19 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.166 2008/05/19 15:46:31 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -592,12 +592,24 @@ do_fingerprint(struct passwd *pw)
static void
print_host(FILE *f, const char *name, Key *public, int hash)
{
- if (hash && (name = host_hash(name, NULL, 0)) == NULL)
- fatal("hash_host failed");
- fprintf(f, "%s ", name);
- if (!key_write(public, f))
- fatal("key_write failed");
- fprintf(f, "\n");
+ if (print_fingerprint) {
+ enum fp_rep rep;
+ enum fp_type fptype;
+ char *fp;
+
+ fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5;
+ rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX;
+ fp = key_fingerprint(public, fptype, rep);
+ printf("%u %s %s\n", key_size(public), fp, name);
+ xfree(fp);
+ } else {
+ if (hash && (name = host_hash(name, NULL, 0)) == NULL)
+ fatal("hash_host failed");
+ fprintf(f, "%s ", name);
+ if (!key_write(public, f))
+ fatal("key_write failed");
+ fprintf(f, "\n");
+ }
}
static void
@@ -1218,6 +1230,10 @@ main(int argc, char **argv)
printf("Can only have one of -p and -c.\n");
usage();
}
+ if (print_fingerprint && (delete_host || hash_hosts)) {
+ printf("Cannot use -l with -D or -R.\n");
+ usage();
+ }
if (delete_host || hash_hosts || find_host)
do_known_hosts(pw, rr_hostname);
if (print_fingerprint || print_bubblebabble)