summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-07-17 03:43:42 +0000
committerDamien Miller <djm@mindrot.org>2020-07-17 13:52:46 +1000
commit8df5774a42d2eaffe057bd7f293fc6a4b1aa411c (patch)
tree16e1028b667e7f3fc41034da48367165e1110741 /ssh.c
parentc4f239944a4351810fd317edf408bdcd5c0102d9 (diff)
upstream: Add a '%k' TOKEN that expands to the effective HostKey of
the destination. This allows, eg, keeping host keys in individual files using "UserKnownHostsFile ~/.ssh/known_hosts.d/%k". bz#1654, ok djm@, jmc@ (man page bits) OpenBSD-Commit-ID: 7084d723c9cc987a5c47194219efd099af5beadc
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ssh.c b/ssh.c
index 5c93c3d2f..93e5c4831 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.532 2020/07/17 03:23:10 dtucker Exp $ */ 1/* $OpenBSD: ssh.c,v 1.533 2020/07/17 03:43:42 dtucker 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
@@ -176,6 +176,7 @@ char *forward_agent_sock_path = NULL;
176/* Various strings used to to percent_expand() arguments */ 176/* Various strings used to to percent_expand() arguments */
177static char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; 177static char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
178static char uidstr[32], *host_arg, *conn_hash_hex; 178static char uidstr[32], *host_arg, *conn_hash_hex;
179static const char *keyalias;
179 180
180/* socket address the host resolves to */ 181/* socket address the host resolves to */
181struct sockaddr_storage hostaddr; 182struct sockaddr_storage hostaddr;
@@ -235,6 +236,7 @@ tilde_expand_paths(char **paths, u_int num_paths)
235 "C", conn_hash_hex, \ 236 "C", conn_hash_hex, \
236 "L", shorthost, \ 237 "L", shorthost, \
237 "i", uidstr, \ 238 "i", uidstr, \
239 "k", keyalias, \
238 "l", thishost, \ 240 "l", thishost, \
239 "n", host_arg, \ 241 "n", host_arg, \
240 "p", portstr 242 "p", portstr
@@ -1380,6 +1382,7 @@ main(int ac, char **av)
1380 snprintf(portstr, sizeof(portstr), "%d", options.port); 1382 snprintf(portstr, sizeof(portstr), "%d", options.port);
1381 snprintf(uidstr, sizeof(uidstr), "%llu", 1383 snprintf(uidstr, sizeof(uidstr), "%llu",
1382 (unsigned long long)pw->pw_uid); 1384 (unsigned long long)pw->pw_uid);
1385 keyalias = options.host_key_alias ? options.host_key_alias : host_arg;
1383 1386
1384 conn_hash_hex = ssh_connection_hash(thishost, host, portstr, 1387 conn_hash_hex = ssh_connection_hash(thishost, host, portstr,
1385 options.user); 1388 options.user);