summaryrefslogtreecommitdiff
path: root/ssh-keyscan.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2005-05-25 11:01:01 +0000
committerColin Watson <cjwatson@debian.org>2005-05-25 11:01:01 +0000
commite88de75a1a236779a10e8ccbcc51d25308be8840 (patch)
tree7495477a2a7d0cac17a9fcded020b6ea816182ef /ssh-keyscan.c
parent30a0f9443782cd9d7308acd09430bf586186aa55 (diff)
parent5d05471f6657646d1d6500c7c43134462c407ee6 (diff)
Merge 4.0p1 to the trunk.
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 2f9221605..7d10c6c3e 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.52 2005/03/01 15:47:14 jmc 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 [-46Hv] [-f file] [-p port] [-T timeout] [-t type]\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) {