2

I created a section within my SSH Config file, but I have a letter case issue when trying to execute my ProxyCommand where once I input SystemDevice it reads back in the config file as systemdevice -- in lower case. It's not executing with my exact input. I did some research and I came across %n may solve my issue, but that doesn't work with ProxyCommand. I receive percent_expand: unknown key %n if I try use it.

Reading the man page, it states:

ProxyCommand accepts the tokens %%, %h, %p, and %r.

My SSH Config:

Host SystemDevice*
    User test
    ProxyCommand socat UNIX:/Devices/%h -

My error when trying to run ssh SystemDevice1001:

socat[4088] E connect(5, AF=1 "/Devices/systemdevice1001", 39): No such file or directory
ssh_exchange_identification: Connection closed by remote host

If I change my config to work with lowercase it works a charm! Thing is, I can work with lowercase, but for my own knowledge I would love to see if there's a solution to this! I couldn't find anything online relating to this.

My OS: Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-119-generic x86_64)

4
  • I can't spot anything in the OpenSSH source code that lowercases the hostname at the moment. But I'll keep reading.
    – Kusalananda
    Commented Apr 13, 2018 at 14:24
  • Hmm, i been searching myself and not sure why it would lowercase? Thought maybe theres another way i can pass in. Commented Apr 13, 2018 at 14:28
  • You could try using %n instead of %h. That should give you the original host name as it was specified on the command line. Do you have CanonicalizeHostname set?
    – Kusalananda
    Commented Apr 13, 2018 at 14:32
  • As i stated in my question, %n doesnt work with proxycommand. I receive percent_expand: unknown key %n if i use it. As for CanonicalizeHostname im not sure i follow what that is? Commented Apr 13, 2018 at 14:38

1 Answer 1

3

I just ran into this issue as well. Seems like a bug in openssh, and I don't think there is a way to avoid it.

I looked into the openssh sourcecode and found a call in main.c to function 'lowercase()'. Only reason I can think of for this is that DNS hostnames are normally caseless:

1038
1039         /* If canonicalization requested then try to apply it */
1040         lowercase(host);
1041         if (options.canonicalize_hostname != SSH_CANONICALISE_NO)
1042                 addrs = resolve_canonicalize(&host, options.port);
1043

Later on this same 'host' variable is used in the 'ssh_connect':

1266         /* Open a connection to the remote host. */
1267         if (ssh_connect(host, addrs, &hostaddr, options.port,
1268             options.address_family, options.connection_attempts,
1269             &timeout_ms, options.tcp_keep_alive,
1270             options.use_privileged_port) != 0)
1271                 exit(255);

Finally, the sshconnect.c code also shows that only %h, %p, and %r are supported in ProxyCommand:

87   expand_proxy_command(const char *proxy_command, const char *user,
88       const char *host, int port)
89   {
90           char *tmp, *ret, strport[NI_MAXSERV];
91
92           snprintf(strport, sizeof strport, "%d", port);
93           xasprintf(&tmp, "exec %s", proxy_command);
94           ret = percent_expand(tmp, "h", host, "p", strport,
95               "r", options.user, (char *)NULL);
96           free(tmp);
97           return ret;
98   }

I too need the original 'Uppercase' name in the ProxyCommand. Only way to get it is to remove the '*' and hard code without %h. I will need an entry for each host...

You must log in to answer this question.

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