/etc/ssh/sshd_config disables it or when client-side SSH keys override password prompts. This guide resolves configuration errors, verifies service status, and ensures proper permissions to restore standard login methods.
Verify Server Configuration
The primary cause for this issue is often an incorrect setting in the Secure Shell daemon configuration file. Ubuntu 24.04 may ship with strict defaults or previous administrators may have modified security policies. You must edit the /etc/ssh/sshd_config file using a text editor with root privileges.
sudo nano /etc/ssh/sshd_config
Locate the line that begins with PasswordAuthentication. It is frequently commented out with a hash symbol (#) or explicitly set to no. Change this value to yes:
PasswordAuthentication yes
Additionally, ensure that PermitRootLogin is set appropriately if you are attempting to log in as the root user. Setting it to prohibit-password allows password login but blocks key-based login for root, while yes allows both. After making changes, save the file and exit the editor.
Restart the SSH Service
Changes to sshd_config do not take effect immediately. You must restart the SSH service to apply the new configuration. Use the following command to reload the daemon:
sudo systemctl restart ssh
Verify that the service is running without errors by checking its status:
sudo systemctl status ssh
If the service fails to start, check the logs for syntax errors in the configuration file. A common mistake is introducing invalid characters or misspelling directive names. Correct any errors and retry the restart command.
Check Client-Side Behavior
Sometimes the issue lies not with the server but with the client machine. Modern SSH clients prioritize public key authentication over passwords. If you have keys configured in your local ~/.ssh directory, the client may attempt to use them silently, failing if they are rejected, and never prompting for a password.
To force password authentication from the client side, use the -o flag to disable identity files:
ssh -o PubkeyAuthentication=no username@server_ip
This forces the SSH client to skip key-based attempts and request a password prompt. If this works, the server configuration is correct, and the issue is client-side key management. You can also remove or rename conflicting keys in ~/.ssh/id_rsa or ~/.ssh/id_ed25519 temporarily to test.
Validate User Permissions and Accounts
Ensure that the user account you are trying to access has a valid password set. An account with no password or one locked by the system will reject password authentication. Check the account status using:
passwd -S username
If the account is locked (indicated by LK), unlock it with:
sudo passwd -u username
Furthermore, verify that the user is not restricted by PAM (Pluggable Authentication Modules) settings. Some systems enforce two-factor authentication or other restrictions that bypass standard password checks. Review /etc/pam.d/sshd if standard fixes fail.
Firewall and Network Considerations
While less likely to cause specific password auth failures, network issues can interrupt the authentication handshake. Ensure that port 22 is open in your firewall. On Ubuntu, ufw manages this:
sudo ufw allow ssh
If you are connecting through a proxy or jump host, ensure that tunneling does not interfere with credential passing. For more details on managing connections through firewalls, see our guide on Setup SSH Connection with 3 Ubuntu Machines to Bypass a Firewall.
Frequently Asked Questions
Why does SSH still ask for a password even after setting PasswordAuthentication to no?
If you set PasswordAuthentication to no, the server should reject password logins entirely. If it still asks, you may be connecting via a different method like keyboard-interactive which some PAM modules support. Check if KbdInteractiveAuthentication is enabled in sshd_config.
Can I use SSH keys instead of passwords for better security?
Yes, key-based authentication is significantly more secure than passwords. Generate a key pair on your client using ssh-keygen and copy the public key to the server using ssh-copy-id. Then disable password authentication on the server to prevent brute-force attacks.
What if I get "Permission Denied" after entering the correct password?
This usually indicates that the user account is locked, lacks a home directory, or has restrictive shell settings. Verify the user exists with id username and check if their shell is set to a valid interpreter like /bin/bash in /etc/passwd.
Does Ubuntu 24.04 disable password login by default?
No, Ubuntu 24.04 typically enables password authentication by default in the base installation. However, cloud images or minimal installs might have stricter configurations. Always verify the sshd_config file after initial setup.
How do I troubleshoot SSH connection timeouts?
Timeouts are often network-related rather than authentication-specific. Use ssh -v to enable verbose mode and see where the connection hangs. If it hangs during authentication, check server logs in /var/log/auth.log for clues about rejected credentials or PAM failures.