- djm@cvs.openbsd.org 2010/07/12 22:41:13

[ssh.c ssh_config.5]
     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@
This commit is contained in:
Damien Miller 2010-07-16 13:56:43 +10:00
parent 1f25ab43f4
commit d0244d498b
3 changed files with 26 additions and 9 deletions

View File

@ -10,6 +10,18 @@
[ssh.c] [ssh.c]
Make ExitOnForwardFailure work with fork-after-authentication ("ssh -f") Make ExitOnForwardFailure work with fork-after-authentication ("ssh -f")
for protocol 2. ok markus@ for protocol 2. ok markus@
- djm@cvs.openbsd.org 2010/07/12 22:41:13
[ssh.c ssh_config.5]
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@
20100714 20100714
- (tim) [contrib/redhat/openssh.spec] Bug 1796: Test for skip_x11_askpass - (tim) [contrib/redhat/openssh.spec] Bug 1796: Test for skip_x11_askpass

15
ssh.c
View File

@ -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> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -679,6 +679,11 @@ main(int ac, char **av)
options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; 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) { if (options.local_command != NULL) {
char thishost[NI_MAXHOST]; char thishost[NI_MAXHOST];
@ -688,16 +693,12 @@ main(int ac, char **av)
debug3("expanding LocalCommand: %s", options.local_command); debug3("expanding LocalCommand: %s", options.local_command);
cp = options.local_command; cp = options.local_command;
options.local_command = percent_expand(cp, "d", pw->pw_dir, options.local_command = percent_expand(cp, "d", pw->pw_dir,
"h", options.hostname? options.hostname : host, "h", host, "l", thishost, "n", host, "r", options.user,
"l", thishost, "n", host, "r", options.user, "p", buf, "p", buf, "u", pw->pw_name, (char *)NULL);
"u", pw->pw_name, (char *)NULL);
debug3("expanded LocalCommand: %s", options.local_command); debug3("expanded LocalCommand: %s", options.local_command);
xfree(cp); xfree(cp);
} }
if (options.hostname != NULL)
host = options.hostname;
/* force lowercase for hostkey matching */ /* force lowercase for hostkey matching */
if (options.host_key_alias != NULL) { if (options.host_key_alias != NULL) {
for (p = options.host_key_alias; *p; p++) for (p = options.host_key_alias; *p; p++)

View File

@ -34,8 +34,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" 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 $ .\" $OpenBSD: ssh_config.5,v 1.136 2010/07/12 22:41:13 djm Exp $
.Dd $Mdocdate: June 26 2010 $ .Dd $Mdocdate: July 12 2010 $
.Dt SSH_CONFIG 5 .Dt SSH_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -537,6 +537,10 @@ or for multiple servers running on a single host.
.It Cm HostName .It Cm HostName
Specifies the real host name to log into. Specifies the real host name to log into.
This can be used to specify nicknames or abbreviations for hosts. 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. The default is the name given on the command line.
Numeric IP addresses are also permitted (both on the command line and in Numeric IP addresses are also permitted (both on the command line and in
.Cm HostName .Cm HostName