summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2010-07-12 22:41:14 +0000
committerDamien Miller <djm@cvs.openbsd.org>2010-07-12 22:41:14 +0000
commitce5b489f16a8e717964d82e1bf7ddcc7f84939d1 (patch)
tree0c8cf6c7df38c156ab1b529f154a27c90908d91e /usr.bin
parentd38a45302ba56fc07667425f0cf4004193d210e7 (diff)
expand %h to the hostname in ssh_config Hostname options. While this
sounds useless, it is actually handy for working with unqualified hostnames: Host *.* Hostname %h Host * Hostname %h.example.org "I like it" markus@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh.c15
-rw-r--r--usr.bin/ssh/ssh_config.58
2 files changed, 14 insertions, 9 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index e87fb8a0478..2aab1048a31 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.342 2010/07/12 22:38:52 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.343 2010/07/12 22:41:13 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -664,6 +664,11 @@ main(int ac, char **av)
options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
}
+ if (options.hostname != NULL) {
+ host = percent_expand(options.hostname,
+ "h", host, (char *)NULL);
+ }
+
if (options.local_command != NULL) {
char thishost[NI_MAXHOST];
@@ -673,16 +678,12 @@ main(int ac, char **av)
debug3("expanding LocalCommand: %s", options.local_command);
cp = options.local_command;
options.local_command = percent_expand(cp, "d", pw->pw_dir,
- "h", options.hostname? options.hostname : host,
- "l", thishost, "n", host, "r", options.user, "p", buf,
- "u", pw->pw_name, (char *)NULL);
+ "h", host, "l", thishost, "n", host, "r", options.user,
+ "p", buf, "u", pw->pw_name, (char *)NULL);
debug3("expanded LocalCommand: %s", options.local_command);
xfree(cp);
}
- if (options.hostname != NULL)
- host = options.hostname;
-
/* force lowercase for hostkey matching */
if (options.host_key_alias != NULL) {
for (p = options.host_key_alias; *p; p++)
diff --git a/usr.bin/ssh/ssh_config.5 b/usr.bin/ssh/ssh_config.5
index 531a60b5e32..e7bb21ebb43 100644
--- a/usr.bin/ssh/ssh_config.5
+++ b/usr.bin/ssh/ssh_config.5
@@ -34,8 +34,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $OpenBSD: ssh_config.5,v 1.135 2010/06/26 00:57:07 jmc Exp $
-.Dd $Mdocdate: June 26 2010 $
+.\" $OpenBSD: ssh_config.5,v 1.136 2010/07/12 22:41:13 djm Exp $
+.Dd $Mdocdate: July 12 2010 $
.Dt SSH_CONFIG 5
.Os
.Sh NAME
@@ -537,6 +537,10 @@ or for multiple servers running on a single host.
.It Cm HostName
Specifies the real host name to log into.
This can be used to specify nicknames or abbreviations for hosts.
+If the hostname contains the character sequence
+.Ql %h ,
+then this will be replaced with the host name specified on the commandline
+(this is useful for manipulating unqualified names).
The default is the name given on the command line.
Numeric IP addresses are also permitted (both on the command line and in
.Cm HostName