View | Details | Raw Unified | Return to bug 212 | Differences between
and this patch

Collapse All | Expand All

(-)ssh-keyscan.1 (+11 lines)
Lines 19-24 Link Here
19
.Op Fl T Ar timeout
19
.Op Fl T Ar timeout
20
.Op Fl t Ar type
20
.Op Fl t Ar type
21
.Op Fl f Ar file
21
.Op Fl f Ar file
22
.Op Fl n Ar netgroup
22
.Op Ar host | addrlist namelist
23
.Op Ar host | addrlist namelist
23
.Op Ar ...
24
.Op Ar ...
24
.Sh DESCRIPTION
25
.Sh DESCRIPTION
Lines 73-78 is supplied instead of a filename, Link Here
73
will read hosts or
74
will read hosts or
74
.Pa addrlist namelist
75
.Pa addrlist namelist
75
pairs from the standard input.
76
pairs from the standard input.
77
.It Fl n Ar netgroup
78
Specifies that hostnames appear in the 
79
.Pa netgroup
80
specified.  Multiple values may be specified by separating them with commas.
76
.It Fl v
81
.It Fl v
77
Verbose mode.
82
Verbose mode.
78
Causes
83
Causes
Lines 105-110 host key for machine Link Here
105
.Pa hostname :
110
.Pa hostname :
106
.Bd -literal
111
.Bd -literal
107
$ ssh-keyscan hostname
112
$ ssh-keyscan hostname
113
.Ed
114
.Pp
115
Print the version 1 and 2 RSA keys for all hosts in the servers and
116
workstations netgroups
117
.Bd -literal
118
$ ssh-keyscan -t rsa1,rsa -n servers,workstations
108
.Ed
119
.Ed
109
.Pp
120
.Pp
110
Find all hosts from the file
121
Find all hosts from the file
(-)ssh-keyscan.c (-4 / +29 lines)
Lines 14-19 RCSID("$OpenBSD: ssh-keyscan.c,v 1.35 20 Link Here
14
#include <openssl/bn.h>
14
#include <openssl/bn.h>
15
15
16
#include <setjmp.h>
16
#include <setjmp.h>
17
17
#include "xmalloc.h"
18
#include "xmalloc.h"
18
#include "ssh.h"
19
#include "ssh.h"
19
#include "ssh1.h"
20
#include "ssh1.h"
Lines 386-393 tcpconnect(char *host) Link Here
386
	memset(&hints, 0, sizeof(hints));
387
	memset(&hints, 0, sizeof(hints));
387
	hints.ai_family = IPv4or6;
388
	hints.ai_family = IPv4or6;
388
	hints.ai_socktype = SOCK_STREAM;
389
	hints.ai_socktype = SOCK_STREAM;
389
	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
390
	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) {
390
		fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr));
391
		error("getaddrinfo %s: %s", host, gai_strerror(gaierr));
392
		return (-1);
393
	}
391
	for (ai = aitop; ai; ai = ai->ai_next) {
394
	for (ai = aitop; ai; ai = ai->ai_next) {
392
		s = socket(ai->ai_family, SOCK_STREAM, 0);
395
		s = socket(ai->ai_family, SOCK_STREAM, 0);
393
		if (s < 0) {
396
		if (s < 0) {
Lines 680-685 usage(void) Link Here
680
	    __progname);
683
	    __progname);
681
	fprintf(stderr, "Options:\n");
684
	fprintf(stderr, "Options:\n");
682
	fprintf(stderr, "  -f file     Read hosts or addresses from file.\n");
685
	fprintf(stderr, "  -f file     Read hosts or addresses from file.\n");
686
	fprintf(stderr, "  -n netgroup Do all hosts or addresses from netgroup.\n");
683
	fprintf(stderr, "  -p port     Connect to the specified port.\n");
687
	fprintf(stderr, "  -p port     Connect to the specified port.\n");
684
	fprintf(stderr, "  -t keytype  Specify the host key type.\n");
688
	fprintf(stderr, "  -t keytype  Specify the host key type.\n");
685
	fprintf(stderr, "  -T timeout  Set connection timeout.\n");
689
	fprintf(stderr, "  -T timeout  Set connection timeout.\n");
Lines 695-700 main(int argc, char **argv) Link Here
695
	int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO;
699
	int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO;
696
	int opt, fopt_count = 0;
700
	int opt, fopt_count = 0;
697
	char *tname;
701
	char *tname;
702
	char *netgroups = NULL;
698
703
699
	extern int optind;
704
	extern int optind;
700
	extern char *optarg;
705
	extern char *optarg;
Lines 707-713 main(int argc, char **argv) Link Here
707
	if (argc <= 1)
712
	if (argc <= 1)
708
		usage();
713
		usage();
709
714
710
	while ((opt = getopt(argc, argv, "v46p:T:t:f:")) != -1) {
715
	while ((opt = getopt(argc, argv, "v46p:T:t:f:n:")) != -1) {
711
		switch (opt) {
716
		switch (opt) {
712
		case 'p':
717
		case 'p':
713
			ssh_port = a2port(optarg);
718
			ssh_port = a2port(optarg);
Lines 757-762 main(int argc, char **argv) Link Here
757
				tname = strtok(NULL, ",");
762
				tname = strtok(NULL, ",");
758
			}
763
			}
759
			break;
764
			break;
765
		case 'n':
766
			netgroups = xstrdup(optarg);
767
			break;
760
		case '4':
768
		case '4':
761
			IPv4or6 = AF_INET;
769
			IPv4or6 = AF_INET;
762
			break;
770
			break;
Lines 768-774 main(int argc, char **argv) Link Here
768
			usage();
776
			usage();
769
		}
777
		}
770
	}
778
	}
771
	if (optind == argc && !fopt_count)
779
	if (optind == argc && !fopt_count && !netgroups)
772
		usage();
780
		usage();
773
781
774
	log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1);
782
	log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1);
Lines 788-793 main(int argc, char **argv) Link Here
788
	read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask);
796
	read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask);
789
	read_wait = xmalloc(read_wait_size);
797
	read_wait = xmalloc(read_wait_size);
790
	memset(read_wait, 0, read_wait_size);
798
	memset(read_wait, 0, read_wait_size);
799
800
	if (netgroups) {
801
		char *machine, *user, *domain, *curng;
802
		char *token =  netgroups;
803
		while ( (curng = strtok(token, ",")) ) {
804
			if (setnetgrent(curng)) {
805
				while (getnetgrent(&machine, &user, &domain))
806
					if (machine)
807
						do_host(machine);
808
				endnetgrent();
809
			} 
810
			else 
811
				 error("%s: invalid netgroup \"%s\"", __progname, curng);
812
			
813
			token = NULL;
814
		}
815
	}
791
816
792
	if (fopt_count) {
817
	if (fopt_count) {
793
		Linebuf *lb;
818
		Linebuf *lb;

Return to bug 212