SSH (Secure Shell) is a crucial tool for developers, system administrators, and DevOps professionals. However, sometimes SSH password authentication doesn't work, leaving users frustrated. This article will explore the common reasons behind SSH password authentication failures and provide step-by-step solutions. Additionally, if you’re using Windows PowerShell for SSH, I’ll show you how to enable copy and paste, which can be a lifesaver when debugging authentication issues.
Common Reasons Why SSH Password Authentication Fails
There are several reasons why SSH password authentication might not work. Here are the most common:
1. Password Authentication Is Disabled on the Server
Many Linux servers disable password authentication for security reasons, requiring SSH key authentication instead. To check if this is the issue:
- Log in to the server (if possible) and open the SSH configuration file:
sudo nano /etc/ssh/sshd_config
- Look for the following line:
PasswordAuthentication no
- If it's set to
no
, change it toyes
:
PasswordAuthentication yes
- Save the file (Ctrl + X, then Y, then Enter).
- Restart the SSH service:
sudo systemctl restart ssh
2. The User Is Not Allowed to Use SSH
If the SSH user is restricted, authentication will fail. To check:
- Open
/etc/ssh/sshd_config
and look for:
AllowUsers youruser
or
DenyUsers youruser
- Ensure your user is either included in
AllowUsers
or not inDenyUsers
. - Restart the SSH service as shown earlier.
3. Incorrect File and Directory Permissions
SSH is strict about file permissions. If your user's home directory or SSH-related files have incorrect permissions, authentication may fail.
To fix permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/config
Then restart SSH and try logging in again.
4. SSHD Service Not Running
If the SSH service is down, authentication won’t work. Check its status with:
sudo systemctl status ssh
If it's inactive, restart it:
sudo systemctl restart ssh
5. Firewall or Fail2Ban Blocking SSH
A firewall (like ufw
or iptables
) or Fail2Ban could be blocking SSH connections.
To check firewall rules:
sudo ufw status
If SSH is blocked, allow it:
sudo ufw allow ssh
For Fail2Ban, check if your IP is banned:
sudo fail2ban-client status sshd
If you are banned, unban your IP:
sudo fail2ban-client set sshd unbanip YOUR_IP
Fixing SSH Authentication Issues on Windows PowerShell
If you're using Windows PowerShell for SSH, you might also face issues with copy and paste, which can make troubleshooting difficult. Here’s how to enable copy-paste in PowerShell:
1. Enable Quick Edit Mode
- Right-click the PowerShell window’s title bar.
- Click Properties.
- Check the box for QuickEdit Mode.
- Click OK.
This allows you to copy text by highlighting it with your mouse and pasting using right-click.
2. Use Ctrl + C and Ctrl + V for Copy-Paste
Recent PowerShell versions allow Ctrl + C and Ctrl + V for copy-paste. If it doesn’t work:
- Open Windows Terminal settings.
- Under Keyboard shortcuts, ensure Ctrl + C and Ctrl + V are enabled.
Final Thoughts
If your SSH password authentication isn’t working, check:
✅ If password authentication is enabled on the server.
✅ If your user has SSH access.
✅ If file permissions are correct.
✅ If the SSH service is running.
✅ If a firewall or Fail2Ban is blocking SSH.
✅ If you’re using PowerShell, enable copy-paste to simplify debugging.
I hope this guide helps! If you have any questions or solutions, drop a comment below. 🚀
Author Of article : John Agboola Read full article