~/.ssh/config vs etc/hosts?
Solution 1:
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.