summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ssh.c5
-rw-r--r--ssh_config3
-rw-r--r--ssh_config.55
-rw-r--r--sshconnect.c5
4 files changed, 14 insertions, 4 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);
diff --git a/ssh_config b/ssh_config
index 5e8ef548b..842ea866c 100644
--- a/ssh_config
+++ b/ssh_config
@@ -1,4 +1,4 @@
1# $OpenBSD: ssh_config,v 1.34 2019/02/04 02:39:42 dtucker Exp $ 1# $OpenBSD: ssh_config,v 1.35 2020/07/17 03:43:42 dtucker Exp $
2 2
3# This is the ssh client system-wide configuration file. See 3# This is the ssh client system-wide configuration file. See
4# ssh_config(5) for more information. This file provides defaults for 4# ssh_config(5) for more information. This file provides defaults for
@@ -43,3 +43,4 @@
43# VisualHostKey no 43# VisualHostKey no
44# ProxyCommand ssh -q -W %h:%p gateway.example.com 44# ProxyCommand ssh -q -W %h:%p gateway.example.com
45# RekeyLimit 1G 1h 45# RekeyLimit 1G 1h
46# UserKnownHostsFile ~/.ssh/known_hosts.d/%k
diff --git a/ssh_config.5 b/ssh_config.5
index fce59d13a..523ee6973 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -33,7 +33,7 @@
33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: ssh_config.5,v 1.329 2020/07/17 03:23:10 dtucker Exp $ 36.\" $OpenBSD: ssh_config.5,v 1.330 2020/07/17 03:43:42 dtucker Exp $
37.Dd $Mdocdate: July 17 2020 $ 37.Dd $Mdocdate: July 17 2020 $
38.Dt SSH_CONFIG 5 38.Dt SSH_CONFIG 5
39.Os 39.Os
@@ -1850,6 +1850,9 @@ Local user's home directory.
1850The remote hostname. 1850The remote hostname.
1851.It %i 1851.It %i
1852The local user ID. 1852The local user ID.
1853.It %k
1854The host key alias if specified, otherwise the orignal remote hostname given
1855on the command line.
1853.It %L 1856.It %L
1854The local hostname. 1857The local hostname.
1855.It %l 1858.It %l
diff --git a/sshconnect.c b/sshconnect.c
index af08be415..f6d8a1bcf 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.329 2020/03/13 04:01:56 djm Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.330 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
@@ -89,11 +89,14 @@ expand_proxy_command(const char *proxy_command, const char *user,
89 const char *host, const char *host_arg, int port) 89 const char *host, const char *host_arg, int port)
90{ 90{
91 char *tmp, *ret, strport[NI_MAXSERV]; 91 char *tmp, *ret, strport[NI_MAXSERV];
92 const char *keyalias = options.host_key_alias ?
93 options.host_key_alias : host_arg;
92 94
93 snprintf(strport, sizeof strport, "%d", port); 95 snprintf(strport, sizeof strport, "%d", port);
94 xasprintf(&tmp, "exec %s", proxy_command); 96 xasprintf(&tmp, "exec %s", proxy_command);
95 ret = percent_expand(tmp, 97 ret = percent_expand(tmp,
96 "h", host, 98 "h", host,
99 "k", keyalias,
97 "n", host_arg, 100 "n", host_arg,
98 "p", strport, 101 "p", strport,
99 "r", options.user, 102 "r", options.user,