2

I have a long hostname with various arguments in my client config, so I created a second Host entry with the Hostname pointing to the long name (see below).

Host CT106-LongHost-Name-With-Mixed-Case
  Hostname 1.2.3.4

Host CT106
  Hostname CT106-LongHost-Name-With-Mixed-Case
ssh CT106-LongHost-Name-With-Mixed-Case

works fine; however:

ssh CT106

results in an:

ssh: Could not resolve hostname ct106-longhost-name-with-mixed-case: nodename nor servname provided, or not known

I know I can just use the short name for the Host entry and not worry about it, just curious if this is intentional.

2
  • does ssh ct106-longhost-name-with-mixed-case work? As far as my experience goes, host names are always case insensitive Oct 2 at 0:14
  • You could add both aliases to the initial Host directive: Host CT106-LongHost-Name-With-Mixed-Case CT106 should do the trick.
    – Boldewyn
    Oct 2 at 12:15

2 Answers 2

3

Hostnames are case insensitive (RFC 4343, 2) so this is not the cause of your issue.

This is about the structure of ssh_config(5) files.

Host

Restricts the following declarations (up to the next Host or Match keyword) to be only for those hosts that match one of the patterns given after the keyword. - -

Hostname

Specifies the real host name to log into. - -

The CT106 does not match Host CT106-LongHost-Name-With-Mixed-Case. The Hostname specified in this section is not followed as it were given in the original command line, as you expect here, but resolved via DNS. It probably does not resolve to the IP address.

You could specify the IP address directly in the matching Host section:

Host CT106
  Hostname 192.0.2.1
1
  • The DNS specification disagrees. it starts out with they need to be case insensitive and case preserving and then goes out of its way to make that rule of no effect if you're not attempting a zone transfer. Lookup of "CT106" and "ct106" can indeed return different answers.
    – joshudson
    Oct 2 at 16:20
0

Just to add to Esa Jokinen's answer:

to achieve the same effect you can change your config to:

Host CT106 CT106-LongHost-Name-With-Mixed-Case
  Hostname 1.2.3.4

You must log in to answer this question.

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