summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2020-07-17 03:23:10 +0000
committerDamien Miller <djm@mindrot.org>2020-07-17 13:52:46 +1000
commitc4f239944a4351810fd317edf408bdcd5c0102d9 (patch)
treeb2c83f10aad596cc6eba01f94eafe3b43a6bae42
parentdbaaa01daedb423c38124a72c471982fb08a16fb (diff)
upstream: Add %-TOKEN, environment variable and tilde expansion to
UserKnownHostsFile, allowing the file to be automagically split up in the configuration (eg bz#1654). ok djm@, man page parts jmc@ OpenBSD-Commit-ID: 7e1b406caf147638bb51558836a72d6cc0bd1b18
-rw-r--r--ssh.c18
-rw-r--r--ssh_config.518
2 files changed, 30 insertions, 6 deletions
diff --git a/ssh.c b/ssh.c
index b13783d43..5c93c3d2f 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.531 2020/07/05 23:59:45 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.532 2020/07/17 03:23:10 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
@@ -654,6 +654,7 @@ main(int ac, char **av)
654 struct Forward fwd; 654 struct Forward fwd;
655 struct addrinfo *addrs = NULL; 655 struct addrinfo *addrs = NULL;
656 size_t n, len; 656 size_t n, len;
657 u_int j;
657 658
658 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 659 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
659 sanitise_stdfd(); 660 sanitise_stdfd();
@@ -1427,6 +1428,21 @@ main(int ac, char **av)
1427 options.forward_agent_sock_path = cp; 1428 options.forward_agent_sock_path = cp;
1428 } 1429 }
1429 1430
1431 for (j = 0; j < options.num_user_hostfiles; j++) {
1432 if (options.user_hostfiles[j] != NULL) {
1433 cp = tilde_expand_filename(options.user_hostfiles[j],
1434 getuid());
1435 p = default_client_percent_dollar_expand(cp,
1436 pw->pw_dir, host, options.user, pw->pw_name);
1437 if (strcmp(options.user_hostfiles[j], p) != 0)
1438 debug3("expanded UserKnownHostsFile '%s' -> "
1439 "'%s'", options.user_hostfiles[j], p);
1440 free(options.user_hostfiles[j]);
1441 free(cp);
1442 options.user_hostfiles[j] = p;
1443 }
1444 }
1445
1430 for (i = 0; i < options.num_local_forwards; i++) { 1446 for (i = 0; i < options.num_local_forwards; i++) {
1431 if (options.local_forwards[i].listen_path != NULL) { 1447 if (options.local_forwards[i].listen_path != NULL) {
1432 cp = options.local_forwards[i].listen_path; 1448 cp = options.local_forwards[i].listen_path;
diff --git a/ssh_config.5 b/ssh_config.5
index d5c561a10..fce59d13a 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -33,8 +33,8 @@
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.328 2020/05/29 05:48:39 jmc Exp $ 36.\" $OpenBSD: ssh_config.5,v 1.329 2020/07/17 03:23:10 dtucker Exp $
37.Dd $Mdocdate: May 29 2020 $ 37.Dd $Mdocdate: July 17 2020 $
38.Dt SSH_CONFIG 5 38.Dt SSH_CONFIG 5
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -1738,6 +1738,12 @@ having to remember to give the user name on the command line.
1738.It Cm UserKnownHostsFile 1738.It Cm UserKnownHostsFile
1739Specifies one or more files to use for the user 1739Specifies one or more files to use for the user
1740host key database, separated by whitespace. 1740host key database, separated by whitespace.
1741Each filename may use tilde notation to refer to the user's home directory,
1742the tokens described in the
1743.Sx TOKENS
1744section and environment variables as described in the
1745.Sx ENVIRONMENT VARIABLES
1746section.
1741The default is 1747The default is
1742.Pa ~/.ssh/known_hosts , 1748.Pa ~/.ssh/known_hosts ,
1743.Pa ~/.ssh/known_hosts2 . 1749.Pa ~/.ssh/known_hosts2 .
@@ -1874,8 +1880,9 @@ The local username.
1874.Cm LocalForward , 1880.Cm LocalForward ,
1875.Cm Match exec , 1881.Cm Match exec ,
1876.Cm RemoteCommand , 1882.Cm RemoteCommand ,
1883.Cm RemoteForward ,
1877and 1884and
1878.Cm RemoteForward 1885.Com UserKnownHostsFile
1879accept the tokens %%, %C, %d, %h, %i, %L, %l, %n, %p, %r, and %u. 1886accept the tokens %%, %C, %d, %h, %i, %L, %l, %n, %p, %r, and %u.
1880.Pp 1887.Pp
1881.Cm Hostname 1888.Cm Hostname
@@ -1899,9 +1906,10 @@ returned and the setting for that keyword will be ignored.
1899The keywords 1906The keywords
1900.Cm CertificateFile , 1907.Cm CertificateFile ,
1901.Cm ControlPath , 1908.Cm ControlPath ,
1902.Cm IdentityAgent 1909.Cm IdentityAgent ,
1903and
1904.Cm IdentityFile 1910.Cm IdentityFile
1911and
1912.Cm UserKnownHostsFile
1905support environment variables. 1913support environment variables.
1906The keywords 1914The keywords
1907.Cm LocalForward 1915.Cm LocalForward