What's the difference between Host and HostName in SSH Config?
For github.com your ~/.ssh/config
might look like this
Host github.com
IdentityFile ~/.ssh/key_name_for_github
For hostname: as man says it allows you to specify abbreviation for host.
For example, if your ~/.ssh/config
look like this
Host host1
HostName host1.example.com
Host host2
HostName anotherdomain.com
Then when you type
ssh host1
you actually login to host1.example.comssh host2
login to anotherdomain.com
In simple usage:
Host
is the actual hostname & there's no HostName
OR
Host
is the nickname of the host & HostName
is the actual hostname.
Simple example:
$ cat ~/.ssh/config
Host dev
Hostname <hostname>
User <username>
IdentityFile <path_to_private_key>
$ ssh dev
# Equivalent to "ssh -i <path_to_private_key> <username>@<hostname>"
Note: The man page is technically correct, it's just worded a bit strangely. I would add a few more words for clarity: HostName Specifies the real host name to log into. This can be used *TOGETHER WITH 'HOST'* to specify nicknames or abbreviations for hosts.