sudo: unable to resolve host
I logged into a fresh (but very cheap) VPS with Debian installed so first thing I wanted to do was make sure I had the access I need so a real quick file write first:
stevemartin@vps777:~# sudo touch notes.txt sudo: unable to resolve host vps777.verycheaphost.com: Name or service not known What?
You don’t know that you exist?
Why does creating a file check to see if you know you exist?
The server doesn’t know it doesn’t exist because whatever VPS setup template was used renamed the host without updating all the references.
Every sudo call does some reasonable validation of the user and the host. If it can’t find itself it throws this warning but it’s not blocking because you probably need access to things to fix it.
You can validate by looking at /etc/hostname and /etc/hosts
stevemartin@vps777:~# cat /etc/hostname vps777.verycheaphost.com stevemartin@vps777:~# cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 debian # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters The /etc/hostname and /etc/hosts have different references because the host renaming process was incomplete. It can’t find itself because the /etc/hosts assumes it is named debian instead of vps777.verycheaphost.com. The fix is easy enough. Replace the name in /etc/hosts with the actual hostname and also the shortened version because different tools care more about different bits of the name (yes I use vim for everything, get over it).
stevemartin@vps777:~# sudo vim /etc/hosts 127.0.0.1 localhost
127.0.1.1 vps777 vps777.verycheaphost.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
That’s it. The warning is now resolved.