Interview Prep/Linux/SSH, sudo and authentication

`sudo` hangs for several seconds and prints `sudo: unable to resolve host app01: Name or service not known`.

BeginnerTroubleshootingSSH, sudo and authentication
Answer

Likely causes → The hostname was changed but isn't resolvable (missing from /etc/hosts and DNS).

Diagnose →

hostname
getent hosts "$(hostname)"
cat /etc/hosts

Fix → Add 127.0.1.1 app01 (Debian style) or the host's IP and FQDN to /etc/hosts, or fix DNS.

Prevent → Update /etc/hosts whenever the hostname changes (cloud-init manage_etc_hosts: true).

All Linux questions Roadmap: Linux

More on SSH, sudo and authentication