Score:0

Is there a way to prevent SSH from lowercasing the hostname?

cn flag

I'm using an SSH config file with a ProxyCommand to hop through a bastion host to my target host. Specifically, the ProxyCommand uses a cloud service CLI that takes the hostname / user / port I originally passed, looks them up in a database, and connects me to the host through their bastion. It essentially looks like this:

Host host-*
  ProxyCommand /bin/the-cli %h %r %p

The problem is that the database of target hostnames is case-sensitive, i.e. host-XyZ, but SSH always turns the hostname I originally entered (%h) into a lowercase string. So the end result is something like:

$ ssh host-XyZ

Bastion service: there are no targets with name 'xyz'

Can I prevent SSH from doing this? I don't see any documentation of where the remote hostname is being converted to lowercase.

Score:2
cn flag

Use %n instead. Per ssh_config manual

%n    The original remote hostname, as given on the command line.

OpenSSH lowercases %h, which cannot be disabled.

13f97b228 circa 2014 changed something to do with CanonicalizeHostname and ssh_config parsing. It also does a lowercase on the host string. Presumably to allow case insensitive substitution before resolving names.

DNS is supposed to be more or less case-insensitive, which is why they can away with this.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.