summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-08 12:54:29 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-08 12:54:29 +1000
commit0f7e910604a9858d71077a50bffca34299894895 (patch)
treec2f96877db4a1441dbdfc858e1beac144ad93134 /ssh-keygen.c
parentdd39264e4b4fcd5a9fd4141b1f7b10eff09b3f8c (diff)
- djm@cvs.openbsd.org 2008/05/19 15:46:31
[ssh-keygen.c] 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 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 69b16e6f5..a03c6575d 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.165 2008/01/19 22:37:19 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.166 2008/05/19 15:46:31 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -600,12 +600,24 @@ do_fingerprint(struct passwd *pw)
600static void 600static void
601print_host(FILE *f, const char *name, Key *public, int hash) 601print_host(FILE *f, const char *name, Key *public, int hash)
602{ 602{
603 if (hash && (name = host_hash(name, NULL, 0)) == NULL) 603 if (print_fingerprint) {
604 fatal("hash_host failed"); 604 enum fp_rep rep;
605 fprintf(f, "%s ", name); 605 enum fp_type fptype;
606 if (!key_write(public, f)) 606 char *fp;
607 fatal("key_write failed"); 607
608 fprintf(f, "\n"); 608 fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5;
609 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_HEX;
610 fp = key_fingerprint(public, fptype, rep);
611 printf("%u %s %s\n", key_size(public), fp, name);
612 xfree(fp);
613 } else {
614 if (hash && (name = host_hash(name, NULL, 0)) == NULL)
615 fatal("hash_host failed");
616 fprintf(f, "%s ", name);
617 if (!key_write(public, f))
618 fatal("key_write failed");
619 fprintf(f, "\n");
620 }
609} 621}
610 622
611static void 623static void
@@ -1231,6 +1243,10 @@ main(int argc, char **argv)
1231 printf("Can only have one of -p and -c.\n"); 1243 printf("Can only have one of -p and -c.\n");
1232 usage(); 1244 usage();
1233 } 1245 }
1246 if (print_fingerprint && (delete_host || hash_hosts)) {
1247 printf("Cannot use -l with -D or -R.\n");
1248 usage();
1249 }
1234 if (delete_host || hash_hosts || find_host) 1250 if (delete_host || hash_hosts || find_host)
1235 do_known_hosts(pw, rr_hostname); 1251 do_known_hosts(pw, rr_hostname);
1236 if (print_fingerprint || print_bubblebabble) 1252 if (print_fingerprint || print_bubblebabble)