If SSH keeps offering a key when you want to test password login, you can change the authentication methods for a single connection. This affects the client invocation only: it does not delete keys, alter your SSH agent, or change the server’s policy.
ssh -o PreferredAuthentications=password \
-o PubkeyAuthentication=no user@host
Replace user@host with your account and server. OpenSSH will prompt interactively if password authentication is available. Don’t put the password in the command line: that can expose it through shell history or process arguments.
First, distinguish a password from a key passphrase
These prompts ask for different things:
-
Enter passphrase for key ...unlocks a private key on your computer. -
user@host's password:usually asks for the remote account password.
The command above prevents public-key authentication for this connection, so it should avoid a local key passphrase prompt. It cannot make the server accept an account password if the server does not allow that method.
Check what the client will do
Use ssh -G to inspect the effective client configuration without connecting to the server. On Linux or macOS:
ssh -G \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no \
-o PasswordAuthentication=yes user@host |
grep -E '^(preferredauthentications|pubkeyauthentication|passwordauthentication|batchmode) '
In Windows PowerShell, replace grep with Select-String:
ssh -G `
-o PreferredAuthentications=password `
-o PubkeyAuthentication=no `
-o PasswordAuthentication=yes user@host |
Select-String '^(preferredauthentications|pubkeyauthentication|passwordauthentication|batchmode) '
You should see preferredauthentications password and pubkeyauthentication no. ssh -G reports client settings; it does not tell you which methods the remote server allows. If your client configuration disables password authentication, adding -o PasswordAuthentication=yes makes the client willing to use it, but does not override server policy.
For a nonstandard SSH port, add -p to the SSH command:
ssh -p 2222 \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no user@host
For reusable host-specific settings, OpenSSH’s config file can keep the override scoped to one machine. The SSH config examples explain host aliases and how configuration order affects the values SSH uses.
Diagnose the server’s response
If no password prompt appears, enable verbose output on a fresh connection:
ssh -vv -S none \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no user@host
-S none prevents connection-socket reuse from hiding the authentication exchange. In the verbose output, look for the methods the server says can continue:
- If it lists only
publickey, password authentication is not being offered at that stage. A client flag cannot make it appear. - If it lists
passwordbut login fails, check the username, password, account status, and server-side authentication logs. - If it lists
keyboard-interactive, the server may be using a PAM-backed prompt, MFA, or another challenge. That method is distinct from SSH’spasswordmethod.
A server can also require more than one method. For example, a policy that requires publickey,password cannot be satisfied by a password-only connection. Follow the server’s authorized access policy rather than trying to bypass it. If the message is Permission denied (publickey), this guide to diagnosing public-key authentication failures can help narrow down what the server rejected.
When you administer the server
Client settings and server settings are separate. On a Linux server you administer, inspect the effective SSH daemon settings before changing anything:
sudo /usr/sbin/sshd -T |
grep -E '^(passwordauthentication|kbdinteractiveauthentication|pubkeyauthentication|authenticationmethods|permitrootlogin) '
A Match block can make settings differ for a particular user or connection, so a generic result may not represent every login. Root access may also be restricted independently of whether password authentication is enabled for other accounts.
Don’t enable root password login, remove MFA, or weaken host-key checks just to make a test work. If password login is required, make changes only when authorized and consistent with the server’s security policy. Keep verifying the server’s host key; a password prompt is not a reason to ignore a changed or untrusted host identity.
The practical rule is simple: use the client options to choose what your SSH client offers, use verbose output to see what the server offers in return, and treat the server’s authentication policy as authoritative.
I originally published a more detailed version of this guide on the ShadeTerm blog.
I'm also building ShadeTerm — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.
Top comments (0)