SSH key authentication is more secure and more convenient than passwords. This guide covers importing or adding your public key, disabling password login, and optional quality-of-life tweaks for Ubuntu servers.
Add your SSH public key to Ubuntu
You have two options for getting your public key onto the server.
Disable password authentication
Edit the SSH config to reject password-based logins:
sudo nano /etc/ssh/sshd_config.d/50-cloud-init.conf
Set (or uncomment) the following line:
PasswordAuthentication no
Then reload and restart SSH:
sudo systemctl daemon-reload
sudo systemctl restart ssh.service
Passwordless sudo Optional
Since you’re already authenticating with SSH keys, you can skip the password prompt for sudo. Replace <username> with your actual username:
echo "<username> ALL=(ALL) NOPASSWD: ALL" | sudo EDITOR=tee visudo -f /etc/sudoers.d/<username> >/dev/null
Install QEMU Guest Agent (Proxmox VMs) Optional
If this is a Proxmox VM, install and enable the guest agent for proper shutdown signaling and IP reporting:
sudo apt update
sudo apt install qemu-guest-agent -y
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent
You now have a base configuration for your Ubuntu install. You can use this VM as is or read the following article to configure a template for future use.
Creating a Proxmox VM Template with Cloud-Init
Step-by-step guide to building a reusable Proxmox VM template with Cloud-Init — from base Ubuntu setup and hardening to cloning production-ready VMs in seconds.