expansion of %h in HostName field of ssh_config

Michael Madsen mkm at cs.au.dk
Sat Aug 22 23:36:12 EST 2009


Hi

It seems like a nice idea to expand a %h in the HostName field in
ssh_config to the host given as argument to ssh.
often one would have a entry in their ssh_config like:
camel*
        User ...
It's okay if the system knows that the host camel01 fx points to the right host.
But what if the actual host is camel01.daimi.au.dk this is something
you wouldn't like to write in your terminal.

But if the ssh_config was
camel*
        %h.daimi.au.dk
        User ...
Then I can just write ssh camel01 as i would like.
This patch should do the trick. One line of code :)

--- openssh-5.1p1/ssh.c 2009-08-21 20:34:40.000000000 +0200
+++ my-openssh-5.1p1/ssh.c      2009-08-21 20:39:53.000000000 +0200
 -673,9 +673,11 @@
                debug3("expanded LocalCommand: %s", options.local_command);
                xfree(cp);
        }
-
-       if (options.hostname != NULL)
-               host = options.hostname;
+
+       if (options.hostname != NULL) {
+               options.hostname = percent_expand(options.hostname,"h",host);
+               host = options.hostname;
+       }

        /* force lowercase for hostkey matching */
        if (options.host_key_alias != NULL) {

// Michael
-- 
Michael Madsen - mkm at cs.au.dk


More information about the openssh-unix-dev mailing list