diff options
author | 2018-02-23 05:14:05 +0000 | |
---|---|---|
committer | 2018-02-23 05:14:05 +0000 | |
commit | 91fadcfc9ae8649ce109eb631e1f20c33e2f21c4 (patch) | |
tree | 091a51febb793da091f8b090c38f80be426b87ec /usr.bin/ssh/ssh-keyscan.c | |
parent | Add missing braces. (diff) | |
download | wireguard-openbsd-91fadcfc9ae8649ce109eb631e1f20c33e2f21c4.tar.xz wireguard-openbsd-91fadcfc9ae8649ce109eb631e1f20c33e2f21c4.zip |
Add ssh-keyscan -D option to make it print its results in SSHFP format
bz#2821, ok dtucker@
Diffstat (limited to 'usr.bin/ssh/ssh-keyscan.c')
-rw-r--r-- | usr.bin/ssh/ssh-keyscan.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index 0afc71729ba..b5c9539d2d5 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.116 2017/11/25 06:46:22 dtucker Exp $ */ +/* $OpenBSD: ssh-keyscan.c,v 1.117 2018/02/23 05:14:05 djm Exp $ */ /* * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. * @@ -40,6 +40,7 @@ #include "hostfile.h" #include "ssherr.h" #include "ssh_api.h" +#include "dns.h" /* Flag indicating whether IPv4 or IPv6. This can be set on the command line. Default value is AF_UNSPEC means both IPv4 and IPv6. */ @@ -60,6 +61,8 @@ int get_keytypes = KT_RSA|KT_ECDSA|KT_ED25519; int hash_hosts = 0; /* Hash hostname on output */ +int print_sshfp = 0; /* Print SSHFP records instead of known_hosts */ + #define MAXMAXFD 256 /* The number of seconds after which to give up on a TCP connection */ @@ -260,6 +263,11 @@ keyprint_one(const char *host, struct sshkey *key) char *hostport; const char *known_host, *hashed; + if (print_sshfp) { + export_dns_rr(host, key, stdout, 0); + return; + } + hostport = put_host_port(host, ssh_port); lowercase(hostport); if (hash_hosts && (hashed = host_hash(host, NULL, 0)) == NULL) @@ -477,7 +485,8 @@ congreet(int s) confree(s); return; } - fprintf(stderr, "# %s:%d %s\n", c->c_name, ssh_port, chop(buf)); + fprintf(stderr, "%c %s:%d %s\n", print_sshfp ? ';' : '#', + c->c_name, ssh_port, chop(buf)); keygrab_ssh2(c); confree(s); } @@ -601,7 +610,7 @@ static void usage(void) { fprintf(stderr, - "usage: %s [-46cHv] [-f file] [-p port] [-T timeout] [-t type]\n" + "usage: %s [-46cDHv] [-f file] [-p port] [-T timeout] [-t type]\n" "\t\t [host | addrlist namelist] ...\n", __progname); exit(1); @@ -628,7 +637,7 @@ main(int argc, char **argv) if (argc <= 1) usage(); - while ((opt = getopt(argc, argv, "cHv46p:T:t:f:")) != -1) { + while ((opt = getopt(argc, argv, "cDHv46p:T:t:f:")) != -1) { switch (opt) { case 'H': hash_hosts = 1; @@ -636,6 +645,9 @@ main(int argc, char **argv) case 'c': get_cert = 1; break; + case 'D': + print_sshfp = 1; + break; case 'p': ssh_port = a2port(optarg); if (ssh_port <= 0) { |