0

Background

I have the following "Host" entry in my ~/.ssh/config:

Host 101.281.182.816 # randomized for superuser.com posting
    HostName 101.281.182.816
    User me

This partially overlaps with an entry in my /etc/hosts:

101.281.182.816    myserver

Question

Will the above entry in /etc/hosts be redundant if I update my ~/.ssh/config to:

Host 101.281.182.816 # randomized for superuser.com posting
    HostName myserver
    User me

1 Answer 1

2

No, actually quite the opposite.

Currently (HostName 101.281.182.816) when you run ssh 101.281.182.816, it finds the entry in your config and knows that it should connect to the IP 101.281.182.816. There's no name resolution going on.

After the change you're proposing (HostName myserver) when ssh 101.281.182.816 is executed it will find out that the name "101.281.182.816" corresponds to hostname myserver and that hostname has to be resolved. /etc/hosts has the priority when resolving names, so it will be resolved to the IP 101.281.182.816 using the entry in /etc/hosts. If that entry was not present there, your DNS server would be used.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .