summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-03-01 21:48:03 +1100
committerDamien Miller <djm@mindrot.org>2005-03-01 21:48:03 +1100
commitdb7b8171ee084cbbe3a5ec5ef26df88e17aa3905 (patch)
treef51643a0ce9a664867797947bcffbf2e60f9f3fc /ssh-keyscan.c
parente1776155d19db4f3ab2ff42323d6499f0712cfa4 (diff)
- djm@cvs.openbsd.org 2005/03/01 10:41:28
[ssh-keyscan.1 ssh-keyscan.c] option to hash hostnames output by ssh-keyscan; ok markus@ deraadt@
Diffstat (limited to 'ssh-keyscan.c')
-rw-r--r--ssh-keyscan.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 3cb52ac2e..e94867004 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$OpenBSD: ssh-keyscan.c,v 1.50 2004/08/11 21:44:32 avsm Exp $"); 10RCSID("$OpenBSD: ssh-keyscan.c,v 1.51 2005/03/01 10:41:28 djm Exp $");
11 11
12#include "openbsd-compat/sys-queue.h" 12#include "openbsd-compat/sys-queue.h"
13 13
@@ -28,6 +28,7 @@ RCSID("$OpenBSD: ssh-keyscan.c,v 1.50 2004/08/11 21:44:32 avsm Exp $");
28#include "log.h" 28#include "log.h"
29#include "atomicio.h" 29#include "atomicio.h"
30#include "misc.h" 30#include "misc.h"
31#include "hostfile.h"
31 32
32/* Flag indicating whether IPv4 or IPv6. This can be set on the command line. 33/* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
33 Default value is AF_UNSPEC means both IPv4 and IPv6. */ 34 Default value is AF_UNSPEC means both IPv4 and IPv6. */
@@ -41,6 +42,8 @@ int ssh_port = SSH_DEFAULT_PORT;
41 42
42int get_keytypes = KT_RSA1; /* Get only RSA1 keys by default */ 43int get_keytypes = KT_RSA1; /* Get only RSA1 keys by default */
43 44
45int hash_hosts = 0; /* Hash hostname on output */
46
44#define MAXMAXFD 256 47#define MAXMAXFD 256
45 48
46/* The number of seconds after which to give up on a TCP connection */ 49/* The number of seconds after which to give up on a TCP connection */
@@ -366,10 +369,14 @@ keygrab_ssh2(con *c)
366static void 369static void
367keyprint(con *c, Key *key) 370keyprint(con *c, Key *key)
368{ 371{
372 char *host = c->c_output_name ? c->c_output_name : c->c_name;
373
369 if (!key) 374 if (!key)
370 return; 375 return;
376 if (hash_hosts && (host = host_hash(host, NULL, 0)) == NULL)
377 fatal("host_hash failed");
371 378
372 fprintf(stdout, "%s ", c->c_output_name ? c->c_output_name : c->c_name); 379 fprintf(stdout, "%s ", host);
373 key_write(key, stdout); 380 key_write(key, stdout);
374 fputs("\n", stdout); 381 fputs("\n", stdout);
375} 382}
@@ -676,7 +683,7 @@ fatal(const char *fmt,...)
676static void 683static void
677usage(void) 684usage(void)
678{ 685{
679 fprintf(stderr, "usage: %s [-v46] [-p port] [-T timeout] [-t type] [-f file]\n" 686 fprintf(stderr, "usage: %s [-Hv46] [-p port] [-T timeout] [-t type] [-f file]\n"
680 "\t\t [host | addrlist namelist] [...]\n", 687 "\t\t [host | addrlist namelist] [...]\n",
681 __progname); 688 __progname);
682 exit(1); 689 exit(1);
@@ -700,8 +707,11 @@ main(int argc, char **argv)
700 if (argc <= 1) 707 if (argc <= 1)
701 usage(); 708 usage();
702 709
703 while ((opt = getopt(argc, argv, "v46p:T:t:f:")) != -1) { 710 while ((opt = getopt(argc, argv, "Hv46p:T:t:f:")) != -1) {
704 switch (opt) { 711 switch (opt) {
712 case 'H':
713 hash_hosts = 1;
714 break;
705 case 'p': 715 case 'p':
706 ssh_port = a2port(optarg); 716 ssh_port = a2port(optarg);
707 if (ssh_port == 0) { 717 if (ssh_port == 0) {