I have a .ssh/config
file configured to connect to different servers with SSH:
###
# Identity files
###
IdentityFile ~/.ssh/id_dsa_home
IdentityFile ~/.ssh/id_dsa_github
IdentityFile ~/.ssh/id_rsa_bitbucket
###
# Global options
###
PasswordAuthentication no
PubkeyAuthentication yes
Host *
Port 22
Host icarus
User elitalon
HostName 192.168.1.1
Port 54301
Host zeus
User elitalon
HostName 192.168.2.1
Port 54302
Host github
User git
HostName github.com
Host bitbucket
User git
HostName bitbucket.org
This configuration used to work fine. However, since I upgraded to Mac OS X Mountain Lion SSH behaves differently regarding specific Port
values in Host
entries:
- If I try to connect to
zeus
SSH always uses port 22, instead of 54301. - If I remove
Port 22
and try to connect to aHost
without aPort
entry, SSH uses the firstPort
value set (54301 in this example).
After trying different combinations it seems SSH processes all config files but only takes the first value of Port
specified, which is an expected behavior according to man page:
For each parameter, the first obtained value will be used
But man page also states that
The configuration files contain sections separated by ``Host'' specifications, and that section is only applied for hosts that match one of the patterns given in the specification.
so I thought that by not specifying any Port
value, the default port would change only in those sections where actually have a Port
value.
So, how can I setup Host
entries to use port 22 except where another value is specified?
Thanks!