After examining your configuration, the key issue lies in the filesystem structure. The error message explicitly states that /home/myuser/.ssh/authorized_keys
is not a regular file - because in your setup, it's actually a directory.
Your current directory structure shows:
drwx------ 3 myuser myuser 4096 Aug 17 13:24 /home/myuser/.ssh drwx------ 2 myuser myuser 4.0K Aug 17 13:23 /home/myuser/.ssh/authorized_keys -rw------- 1 myuser myuser 396 Aug 17 13:17 /home/myuser/.ssh/authorized_keys/id_rsa.pub
This is incorrect. The authorized_keys
should be a regular file, not a directory containing id_rsa.pub
.
Here's how to fix it:
# First, remove the problematic directory rm -rf ~/.ssh/authorized_keys # Then recreate it as a file and set proper permissions touch ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys # Now add your public key directly to the file cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
After fixing the file structure, verify all permissions are correct:
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys chmod 600 ~/.ssh/id_rsa chmod 644 ~/.ssh/id_rsa.pub
For future troubleshooting, you can use these commands:
# Server-side debugging sudo tail -f /var/log/auth.log # Client-side debugging (in PuTTY) Event Log > SSH > Auth > Public key
If you need to convert keys between formats:
# Convert OpenSSH to PuTTY format puttygen id_rsa -o id_rsa.ppk # Convert PuTTY to OpenSSH format puttygen id_rsa.ppk -O private-openssh -o id_rsa
For production environments, consider these additional measures:
# Disable password authentication sudo nano /etc/ssh/sshd_config
Add/modify these lines:
PasswordAuthentication no ChallengeResponseAuthentication no UsePAM no
Then restart SSH:
sudo systemctl restart sshd
When setting up SSH key authentication between Windows (PuTTY) and Debian, the critical error message authorized_keys is not a regular file
indicates a filesystem permission/type problem. The SSH daemon expects ~/.ssh/authorized_keys
to be a regular file, but in this case it's being treated as a directory.
The original poster's directory listing reveals the root cause:
drwx------ 3 myuser myuser 4096 Aug 17 13:24 /home/myuser/.ssh
drw------- 2 myuser myuser 4.0K Aug 17 13:23 /home/myuser/.ssh/authorized_keys
-rw------- 1 myuser myuser 396 Aug 17 13:17 /home/myuser/.ssh/authorized_keys/id_rsa.pub
Notice the directory flag (d) on authorized_keys. The public key is actually stored inside this directory as id_rsa.pub, which is incorrect.
The proper structure should be:
drwx------ 2 myuser myuser 4096 Aug 17 13:24 /home/myuser/.ssh
-rw------- 1 myuser myuser 396 Aug 17 13:17 /home/myuser/.ssh/authorized_keys
Here's how to correct the issue:
# Remove the incorrect directory
rm -rf ~/.ssh/authorized_keys
# Create the proper file and set permissions
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
# Add the public key (single line!)
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
After making these changes:
- Ensure the file exists:
ls -la ~/.ssh/authorized_keys
- Verify the content:
cat ~/.ssh/authorized_keys
- Check permissions:
stat ~/.ssh/authorized_keys
For enterprise environments, consider these additional measures:
# Set strict home directory permissions
chmod 750 ~/
chmod 700 ~/.ssh
# Optional: Make authorized_keys immutable
chattr +i ~/.ssh/authorized_keys
When testing, run the SSH daemon in debug mode:
sudo /usr/sbin/sshd -d -p 2222
Then connect from PuTTY while watching server logs:
tail -f /var/log/auth.log
For Windows clients:
- Ensure Pageant is running with the correct .ppk key
- In PuTTY Configuration:
- Connection > SSH > Auth: Enable "Allow agent forwarding"
- Connection > Data: Set auto-login username
Watch out for:
- Windows line endings in authorized_keys
- Incorrect SELinux contexts (check with
ls -Z
) - Missing newline at end of authorized_keys file
- Overly restrictive parent directory permissions