DigitalOcean Ubuntu Droplet登录异常:SSH公钥认证失败及控制台登录问题
Hey Corey, sorry to hear you're stuck with this frustrating login roadblock on your DigitalOcean Droplet—let’s walk through practical fixes step by step to get you back in control.
First: Fix Console Login Failures
If resetting the root password didn’t let you log in via the DigitalOcean console, start here:
- Double-check password input: The console doesn’t show any characters (not even asterisks) when you type your password. Don’t assume it’s not registering—slowly enter the exact reset password, paying attention to case and special characters.
- Wait for password propagation: Sometimes password resets take 1-2 minutes to fully apply, especially if the Droplet is under heavy load. Give it a moment before retrying.
- Verify Droplet health: Head to your DigitalOcean dashboard to confirm the Droplet is running normally. If CPU/memory is maxed out, the system might be too unresponsive to handle login requests—you may need to restart the Droplet from the dashboard first.
Next: Resolve SSH "Permission denied (publickey)"
Once you can access the console (or use Recovery Mode if console still fails), tackle the SSH issue:
1. Audit SSH Daemon Configuration
Edit the SSH config file with nano /etc/ssh/sshd_config and verify these critical settings:
PasswordAuthentication: Set toyestemporarily if you want to use password login (you can switch back tonoonce keys are fixed).PubkeyAuthentication: Must beyesif you plan to use SSH keys.PermitRootLogin: If it’s set toprohibit-password, root can only use key login—change toyesif you need to test root password login (revert later for security).
Save changes and restart SSH:
systemctl restart sshd # Or use this for older systems: service ssh restart
2. Fix Key File Permissions
SSH rejects keys if permissions are too open. For the root user (or your non-root user), run these commands:
chmod 700 /root/.ssh chmod 600 /root/.ssh/authorized_keys
Double-check that your local public key is present in /root/.ssh/authorized_keys—no accidental deletions or typos here matter.
3. Check Non-Root User Access
If you previously used a non-root user:
- Verify their
~/.ssh/authorized_keyshas the correct permissions (same as above). - Ensure their entry in
/etc/passwdisn’t corrupted (it should end with a valid shell like/bin/bash).
If Console Still Won’t Work: Use Recovery Mode
DigitalOcean’s Recovery Mode lets you access your Droplet’s filesystem directly:
- Power off the Droplet from the dashboard, then enable Recovery Mode and power it back on.
- Connect via the console, follow prompts to mount your Droplet’s main partition (usually
/dev/vda1to/mnt). - Navigate to
/mnt/etc/sshto editsshd_config, or check/mnt/root/.ssh/authorized_keysto fix key issues. - Unmount the partition and restart the Droplet in normal mode.
Extra Checks for Sudden Failures
Since this worked yesterday, rule out these edge cases:
- System tampering: Check auth logs with
cat /var/log/auth.log(or/var/log/secureon RHEL-based systems) for unusual login attempts or configuration changes. - Local SSH cache: Clear old host entries on your local machine with
ssh-keygen -R 162.243.123.123, then retry the SSH connection.
Let me know if any of these steps get you back in, or if you hit other snags—I’m happy to dig deeper with you.
内容的提问来源于stack exchange,提问作者Corey

