Shared by @futuretrees
Have the client run this exact block on the Debian server.
Temporary password already filled in below. Change it immediately after first login.
sudo adduser --disabled-password --gecos "" peyton
sudo usermod -aG sudo peyton
sudo install -d -m 700 -o peyton -g peyton /home/peyton/.ssh
sudo tee /home/peyton/.ssh/authorized_keys >/dev/null <<'EOF'
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPYZJllfLZ4wsb7boMu2HQvedMcfqv4Uj0mEA5Nd7LEU [email protected]
EOF
sudo chown peyton:peyton /home/peyton/.ssh/authorized_keys
sudo chmod 600 /home/peyton/.ssh/authorized_keys
echo 'peyton:PeytonTemp!9472-Kite' | sudo chpasswd
id peyton
ssh peyton@YOUR_SERVER_IP
After logging in:
passwd
sudo whoami
Expected output:
root
--disabled-password--disabled-password means the account is created without a usable password, but SSH key login still works.
So:
sudo behavior immediatelysudo usually expects the user's passwordIf you truly want to leave the account with no password for now, the client can stop before the chpasswd line — but then someone with existing root/sudo access should set Peyton's password later with:
sudo passwd peyton
peytonpeyton to the Debian sudo group/home/peyton/.sshssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPYZJllfLZ4wsb7boMu2HQvedMcfqv4Uj0mEA5Nd7LEU [email protected]
ls -ld /home/peyton/.ssh
ls -l /home/peyton/.ssh/authorized_keys
sudo cat /home/peyton/.ssh/authorized_keys
id peyton
For dead-simple setup: have the client run the block at the top, let Peyton SSH in with the key, then run passwd to change the temporary password and sudo whoami to confirm sudo access.