Skip to main content
minor
Source Link
Mike B
  • 666
  • 7
  • 7

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 mentallywould add a few more words when I read it (shown in caps)for clarity: HostName Specifies the real host name to log into. This can be used TOGETHER*TOGETHER WITH 'HOST''HOST'* to specify nicknames or abbreviations for hosts.

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 mentally add a few words when I read it (shown in caps): HostName Specifies the real host name to log into. This can be used TOGETHER WITH 'HOST' to specify nicknames or abbreviations for hosts.

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.

Simplified & focused content
Source Link
Mike B
  • 666
  • 7
  • 7

I know this question is super old, but figuring out the right answer was driving me crazy (because the man explanations seem contradictory).

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: I've found nicknames can be problematic with any services that give you example commandsThe man page is technically correct, e.git's just worded a bit strangely.:

$ cat ~/.ssh/config
Host git
    Hostname github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Permission denied (publickey). # Failure

You either have to edit the example command to use your nickname or put the actual hostname I mentally add a few words when I read it (shown in thecaps): HostHostName Specifies the real host name to log into. This can be used TOGETHER WITH 'HOST' to specify nicknames or abbreviations for hosts. field.

$ cat ~/.ssh/config
Host github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Cloning... # Success!

I know this question is super old, but figuring out the right answer was driving me crazy (because the man explanations seem contradictory).

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: I've found nicknames can be problematic with any services that give you example commands, e.g.:

$ cat ~/.ssh/config
Host git
    Hostname github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Permission denied (publickey). # Failure

You either have to edit the example command to use your nickname or put the actual hostname in the Host field.

$ cat ~/.ssh/config
Host github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Cloning... # Success!

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 mentally add a few words when I read it (shown in caps): HostName Specifies the real host name to log into. This can be used TOGETHER WITH 'HOST' to specify nicknames or abbreviations for hosts.

deleted 105 characters in body
Source Link
Mike B
  • 666
  • 7
  • 7

I know this question is super old, but figuring out the right answer was driving me crazy (because the man explanations seem contradictory and the other answer to this question is simply wrong).

In commonsimple usage:

Host is for the actual hostname & there's no HostName

OR

Host is the nickname of the host. & (You can do fancier things with this field, but that's outside the scope of this answer.)

HostnameHostName is for 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: II've found there's a slight complication for git repo servers, because often theirnicknames can be problematic with any services that give you example command uses the full hostnamecommands, e.g.:

$ cat ~/.ssh/config
Host git
    Hostname github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Permission denied (publickey). # Failure

For a host like this, it probably makes more sense forYou either have to edit the example command to use your nickname or put the actual hostname in the Host value to be the full hostnamefield.

$ cat ~/.ssh/config
Host github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Cloning... # Success!

I know this question is super old, but figuring out the right answer was driving me crazy (because the man explanations seem contradictory and the other answer to this question is simply wrong).

In common usage:

Host is for the nickname of the host. (You can do fancier things with this field, but that's outside the scope of this answer.)

Hostname is for 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: I found there's a slight complication for git repo servers, because often their example command uses the full hostname, e.g.:

$ cat ~/.ssh/config
Host git
    Hostname github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Permission denied (publickey). # Failure

For a host like this, it probably makes more sense for the Host value to be the full hostname.

$ cat ~/.ssh/config
Host github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Cloning... # Success!

I know this question is super old, but figuring out the right answer was driving me crazy (because the man explanations seem contradictory).

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: I've found nicknames can be problematic with any services that give you example commands, e.g.:

$ cat ~/.ssh/config
Host git
    Hostname github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Permission denied (publickey). # Failure

You either have to edit the example command to use your nickname or put the actual hostname in the Host field.

$ cat ~/.ssh/config
Host github.com
    User <username>
    IdentityFile <path_to_private_key>

$ git clone [email protected]:<username>/<project>.git
Cloning... # Success!
The use of path_to_public_key should be path_to_PRIVATE_key. The ssh command doesn't work with path_to_public_key.
Source Link
Loading
Source Link
Mike B
  • 666
  • 7
  • 7
Loading