Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The man page says this:

Host

Host Restricts the following declarations (up to the next Host keyword) to be only for those hosts that match one of the patterns given after the keyword. If more than one pattern is provided, they should be separated by whitespace. A single `*' as a pattern can be used to provide global defaults for all hosts. The host is the hostname argument given on the command line (i.e. the name is not converted to a canonicalized host name before matching).

A pattern entry may be negated by prefixing it with an exclamation mark (`!'). If a negated entry is matched, then the Host entry is ignored, regardless of whether any other patterns on the line match. Negated matches are therefore useful to provide exceptions for wildcard matches.>

See PATTERNS for more information on patterns.

HostName

HostName Specifies the real host name to log into. This can be used to specify nicknames or abbreviations for hosts. If the hostname contains the character sequence `%h', then this will be replaced with the host name specified on the command line (this is useful for manipulating unqualified names). The default is the name given on the com- mand line. Numeric IP addresses are also permitted (both on the command line and in HostName specifications).

For example, when I want to create an SSH Config for GitHub, what should Host and HostName be respectively?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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
    host1.example.com
Host host2
    anotherdomain.com

Then when you type

ssh host1

you actually login to host1.example.com

ssh host2

login to anotherdomain.com

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.