Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why would ssh fail to expand %h from .ssh/config? This used to work and still works except on a RHEL box. Looking for what the origin of this could be. Is there a setting somewhere that tells ssh to not expand %h?

I have something like this in my .ssh/config:

Host *.foo
  HostName %h.mydomain.com

On the RHEL box where this doesn't work, I get this:

$ ssh -vvvv bar.foo
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /home/zsimic/.ssh/config
debug1: Applying options for *.foo
debug1: Applying options for *.foo
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname %h.mydomain.com: Name or service not known
share|improve this question
up vote 8 down vote accepted

You are using OpenSSH 5.3; %h was only introduced in OpenSSH 5.6:

Changes since OpenSSH 5.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
share|improve this answer
    
That explains it, thanks! – Zoran Sep 26 '12 at 20:38

man ssh_config does not mention that %h will be expanded in HostName clause. I'm using openssh5.9p1

edit: it did and I missed it

If setting up some proxy server ( a local-only one will do ) won't bother you, maybe some workaround with ProxyCommand is possible.

Or, you can enumerate a few hostnames in .ssh/config .

share|improve this answer
    
It used to work, and just stopped working on RHEL 6.1 with a recent update... I thought %h would be expanded everywhere, are you saying it's a gray area in the spec? – Zoran Sep 26 '12 at 3:01
    
MAN on my machine did mention %h and I missed it. You may want to revoke the upvote. Equally confused now. – Jokester Sep 26 '12 at 3:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .