summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-07-19 03:38:01 +0000
committerDamien Miller <djm@mindrot.org>2019-07-19 13:53:27 +1000
commitbca0582063f148c7ddf409ec51435a5a726bee4c (patch)
tree1f330979be2acd505973a07a1d7dc44651e93b3c
parent5299a09fa2879a068af200c91028fcfa9283c0f0 (diff)
upstream: Accept the verbose flag when searching for host keys in known
hosts (i.e. "ssh-keygen -vF host") to print the matching host's random- art signature too. bz#3003 "amusing, pretty" deraadt@ OpenBSD-Commit-ID: 686221a5447d6507f40a2ffba5393984d889891f
-rw-r--r--ssh-keygen.15
-rw-r--r--ssh-keygen.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/ssh-keygen.1 b/ssh-keygen.1
index 8184a1797..b4bc336f2 100644
--- a/ssh-keygen.1
+++ b/ssh-keygen.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-keygen.1,v 1.161 2019/07/15 13:16:29 djm Exp $ 1.\" $OpenBSD: ssh-keygen.1,v 1.162 2019/07/19 03:38:01 djm Exp $
2.\" 2.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -35,7 +35,7 @@
35.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37.\" 37.\"
38.Dd $Mdocdate: July 15 2019 $ 38.Dd $Mdocdate: July 19 2019 $
39.Dt SSH-KEYGEN 1 39.Dt SSH-KEYGEN 1
40.Os 40.Os
41.Sh NAME 41.Sh NAME
@@ -87,6 +87,7 @@
87.Fl F Ar hostname 87.Fl F Ar hostname
88.Op Fl f Ar known_hosts_file 88.Op Fl f Ar known_hosts_file
89.Op Fl l 89.Op Fl l
90.Op Fl v
90.Nm ssh-keygen 91.Nm ssh-keygen
91.Fl H 92.Fl H
92.Op Fl f Ar known_hosts_file 93.Op Fl f Ar known_hosts_file
diff --git a/ssh-keygen.c b/ssh-keygen.c
index c2cfe8df0..ea3c0e638 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.337 2019/07/16 13:18:39 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.338 2019/07/19 03:38:01 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
@@ -1172,7 +1172,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
1172 struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx; 1172 struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx;
1173 enum sshkey_fp_rep rep; 1173 enum sshkey_fp_rep rep;
1174 int fptype; 1174 int fptype;
1175 char *fp; 1175 char *fp = NULL, *ra = NULL;
1176 1176
1177 fptype = print_bubblebabble ? SSH_DIGEST_SHA1 : fingerprint_hash; 1177 fptype = print_bubblebabble ? SSH_DIGEST_SHA1 : fingerprint_hash;
1178 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_DEFAULT; 1178 rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_DEFAULT;
@@ -1206,8 +1206,16 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
1206 known_hosts_hash(l, ctx); 1206 known_hosts_hash(l, ctx);
1207 else if (print_fingerprint) { 1207 else if (print_fingerprint) {
1208 fp = sshkey_fingerprint(l->key, fptype, rep); 1208 fp = sshkey_fingerprint(l->key, fptype, rep);
1209 ra = sshkey_fingerprint(l->key,
1210 fingerprint_hash, SSH_FP_RANDOMART);
1211 if (fp == NULL || ra == NULL)
1212 fatal("%s: sshkey_fingerprint failed",
1213 __func__);
1209 mprintf("%s %s %s %s\n", ctx->host, 1214 mprintf("%s %s %s %s\n", ctx->host,
1210 sshkey_type(l->key), fp, l->comment); 1215 sshkey_type(l->key), fp, l->comment);
1216 if (log_level_get() >= SYSLOG_LEVEL_VERBOSE)
1217 printf("%s\n", ra);
1218 free(ra);
1211 free(fp); 1219 free(fp);
1212 } else 1220 } else
1213 fprintf(ctx->out, "%s\n", l->line); 1221 fprintf(ctx->out, "%s\n", l->line);