A palavra-chave Host
corresponde ao host taraget fornecido na linha de comando.
Assim, ao usar o seguinte arquivo, ssh test-host
se conectará a 192.168.0.1
com o username atual (ou seja: ignorando a configuração específica do IP) - porque test-host
não corresponde a 192.168.0.1
.
Host test-host
Hostname 192.168.0.1
Host 192.168.0.1
User test-user
Para fazer o trabalho acima conforme esperado, você deve definir CanonicalizeHostname=yes
no seu arquivo de configuração. Isso pode ser colocado na seção global (no topo) ou por host, por exemplo:
Host test-host
Hostname 192.168.0.1
CanonicalizeHostname yes
Host 192.168.0.1
User test-user
Isso faria com que o test-host
fosse reescrito 192.168.0.1
.
Observe que ProxyCommand
tem semântica especial:
CanonicalizeHostname
Controls whether explicit hostname canonicalization is performed. The default,
no
, is not to perform any name rewriting and let the system resolver handle all hostname lookups. If set toyes
then, for connections that do not use aProxyCommand
,ssh(1)
will attempt to canonicalize the hostname specified on the command line using theCanonicalDomains
suffixes andCanonicalizePermittedCNAMEs
rules. IfCanonicalizeHostname
is set toalways
, then canonicalization is applied to proxied connections too.If this option is enabled, then the configuration files are processed again using the new target name to pick up any new configuration in matching
Host
andMatch
stanzas.
Alternativas para alcançar o comportamento que você procura são:
A
host server1
user myUser1
hostname 192.168.0.1
host server2
user myUser
hostname 192.168.0.2
host server1 server2
# global config here (such as proxycommand, etc)
B
host 192.168.0.1
user myUser1
host 192.168.0.2
user myUser
host 192.168.0.*
# global config here (such as proxycommand, etc)