← Back to blog

How to Force SSH to Use Password Instead of Key

·
SSH force password authentication instead of public key using OpenSSH commands

To force OpenSSH to ask for a server account password instead of using an SSH key, set PreferredAuthentications=password and PubkeyAuthentication=no for that connection. Your private keys and SSH agent remain untouched.

This works in Windows PowerShell, Linux and macOS when the server allows the password method. If the server accepts only public keys or requires a key before a password, client-side flags cannot bypass that policy.

What you wantWhat to do
Ask for the account passwordPreferredAuthentications=password plus PubkeyAuthentication=no
Avoid the private-key passphrase promptStop public-key attempts for this connection; server password login must still be enabled
Find out why there is no password promptInspect ssh -G and ssh -vv output
Keep the option for one machineUse a host-specific entry in ~/.ssh/config

Force SSH to Use a Password Instead of a Key

For a single login, use the following client-side override. It does not change any setting on the SSH server:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host

PreferredAuthentications=password selects the SSH protocol method named password. PubkeyAuthentication=no explicitly prevents offers from identity files and ssh-agent. Using both makes the intent unambiguous, even though selecting only password would ordinarily exclude public keys already.

If a global client setting explicitly disables password authentication, add -o PasswordAuthentication=yes to your command. That enables the method in your client; it cannot turn it on at the server. Use -p 2222 if your SSH service actually listens on port 2222, or keep the default port 22.

ssh -p 2222 -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host

Important: a request for Enter passphrase for key ... unlocks a local private key; a prompt resembling user@host's password: usually requests a server account password. They are not interchangeable.

Verify That SSH Is Not Using Your Key

Start by seeing what your ordinary login does. On a host where a key is accepted, ssh -v user@host may report that it is offering a public key and then authenticating with publickey. That establishes the baseline; a key configured on one machine may not work on another.

ssh -v user@host
Verbose OpenSSH log from a controlled key-based connection showing an offered public key and authenticated method
Baseline: key-based login. In a successful key test, verbose output identifies the public-key offer and the method used to authenticate. A key-based login must actually succeed before it can be described this way.

Next, confirm the effective client settings without contacting the server. In 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, use Select-String instead of grep:

ssh -G -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes user@host | Select-String "^(preferredauthentications|pubkeyauthentication|passwordauthentication|batchmode) "

Look for preferredauthentications password, pubkeyauthentication no and passwordauthentication yes. ssh -G proves which settings the client would use; it does not prove that a remote server accepts the password method.

PowerShell ssh -G output confirming preferredauthentications password and pubkeyauthentication no
Password-only client settings. The effective OpenSSH configuration shows password preference, disabled public-key authentication and whether interactive prompting is permitted.

Verify a Successful Password Login

The most convincing test is a successful login where verbose output confirms the method. Perform this on a disposable SSH account or a local test container with password login deliberately enabled. Do not enable password login for root on a production VPS solely for a screenshot.

ssh -vv -p 2222 -S none -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes [email protected]

The example uses a locally hosted SSH lab on port 2222; it is not intended for the production host. When the test succeeds, look for Next authentication method: password, the interactive prompt, and a message like Authenticated to ... using "password". The exact log format varies by OpenSSH version. -S none disables connection-socket reuse so an old authenticated session does not hide the new authentication exchange.

Successful local lab SSH session with password prompt and verbose authentication using password
Successful password authentication in a test environment. The screenshot should show a fresh connection and the actual method selected after authentication; no password characters are displayed.

For the exact safe Docker setup used to produce this result, follow the separate ShadeTerm screenshot guide. A password prompt alone is not evidence of a successful login: capture the completion message or the authenticated shell.

Why SSH Does Not Ask for a Password

A correct client command cannot force a server to offer a method it has disabled. If you see Permission denied (publickey) after requesting password-only authentication, the server may currently advertise only public keys, or it may require a public-key step before another method becomes available.

ssh -vv -S none -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host

In verbose output, Authentications that can continue: publickey means that password is not offered at that stage. If it does offer password but rejects the credentials, the diagnosis is different. Check the account, password, PAM/account rules and server logs rather than retrying the same flags indefinitely.

SSH verbose diagnostic showing a server not advertising password authentication in a password-only attempt
Why the password prompt never appears. This negative test documents the actual server-advertised methods. Only describe it as a publickey-only rejection if the captured output confirms that behavior.
Observed symptomLikely explanationNext useful check
Permission denied (publickey)Server offers publickey only at this stagessh -vv, then server policy if you administer it
Permission denied (publickey,password)Password is advertised, but authentication did not succeedCorrect username, account status and server auth logs
keyboard-interactive, but no passwordPAM, challenge or MFA policy uses another methodTry keyboard-interactive only if the server permits it
BatchMode yesYour client suppresses promptsssh -G, interactive BatchMode=no test
No prompt and immediate successConnection multiplexing may reuse a sessionRetest with -S none

Password vs Keyboard-Interactive Authentication

The words “password prompt” and the SSH method password are not always equivalent. A Linux SSH server can also use keyboard-interactive, sometimes backed by PAM or MFA. It may request a password-like answer or an OTP even when the ordinary SSH password method is disabled.

ssh -o PreferredAuthentications=keyboard-interactive,password -o PubkeyAuthentication=no -o KbdInteractiveAuthentication=yes user@host

This explicitly permits a keyboard-interactive challenge before the regular password method. It is not a bypass of MFA, and a keyboard-interactive prompt can request more than a password.

For a server with AuthenticationMethods publickey,password, password-only cannot work: publickey must succeed before password is offered. Follow the authorized server policy or speak to its administrator. See the OpenSSH server configuration manual for the method sequences.

Client Options vs Server Password Policy

All the -o options above configure the client. The server is independently responsible for permitting password authentication, keyboard-interactive prompts, account access and root login. On a Linux server you administer, check its effective global settings without editing anything:

/usr/sbin/sshd -T | grep -E "^(passwordauthentication|kbdinteractiveauthentication|pubkeyauthentication|authenticationmethods|permitrootlogin) "

If you are not root, use sudo /usr/sbin/sshd -T. This check reads server configuration; Match rules may need connection-specific evaluation through sshd -T -C user=...,host=...,addr=.... A root account can be denied password login by PermitRootLogin even when password authentication is enabled for other accounts.

Debian sshd -T output listing passwordauthentication, kbdinteractiveauthentication, authenticationmethods and permitrootlogin
Check the server-side policy. The effective settings explain why a correct client override may still fail; a generic sshd -T result may differ from a user-specific Match configuration.

Our test VPS does not need its configuration changed to perform this inspection. Do not enable root password authentication, change PermitRootLogin, remove MFA or disable host-key checking merely to recreate a tutorial screenshot. Consult our sshd_config guide before making authorized server-side changes.

Force a Password for One Host in SSH Config

If you routinely connect to one test host with a password, put the override in that host’s local SSH client configuration rather than applying it to every server. For example:

Host password-lab
    HostName 127.0.0.1
    Port 2222
    User labuser
    PreferredAuthentications password
    PubkeyAuthentication no
    PasswordAuthentication yes

With the local Docker lab running, connect using ssh password-lab and inspect it with ssh -G password-lab. On Unix-like clients the file is usually ~/.ssh/config; on native Windows OpenSSH it is normally %USERPROFILE%\.ssh\config.

For most settings OpenSSH uses the first value it obtains, so place specific Host entries before broad Host * defaults. A host alias is a preference, not proof of server support. See our SSH config examples for more on precedence.

Windows PowerShell, Linux and macOS Notes

The same OpenSSH -o flags work on Linux, macOS and Windows PowerShell when the OpenSSH client is installed. They do not automatically apply to PuTTY, which has its own settings. WSL may use a separate SSH binary and configuration from native Windows.

Password, passphrase, and prompts

Enter passphrase for key ... means the local key needs unlocking. It does not mean the server rejected your account password. Password-only testing suppresses key offers for this invocation, but routine SSH access is generally better protected by keys and an SSH agent.

BatchMode and connection sharing

If prompts never appear, check ssh -G host for batchmode yes or a configured control socket. For an interactive diagnostic session, add -o BatchMode=no -S none. Do not expect human password prompts inside an unattended script.

Host verification still applies

On the first connection, verify the host-key fingerprint through a trusted source. On a changed host key, investigate the reason instead of using StrictHostKeyChecking=no.

Use Password Authentication with SCP and SFTP

scp and sftp use SSH authentication and pass OpenSSH-style -o options to the underlying connection. On a server that permits passwords:

scp -o PreferredAuthentications=password -o PubkeyAuthentication=no ./file.txt user@host:/tmp/
sftp -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host

For a locally exposed password-lab container on port 2222, a temporary test transfer can use scp -P 2222 ... [email protected]:.... Remember: scp uses uppercase -P for the port, while ssh uses lowercase -p.

These flags select authentication; they do not make a missing SFTP subsystem or an unwritable destination work. For everyday file browsing, ShadeTerm uses SFTP alongside the terminal, rather than claiming to implement the legacy SCP protocol. Read our SCP for Windows and SCP vs SFTP guides for transfer-specific troubleshooting.

FAQ, Troubleshooting and Official References

How do I force SSH to ask for a password instead of a key?

Run ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@host. The server must permit password authentication.

Why do I still get Permission denied (publickey)?

The server may advertise only publickey at that stage or require a key before a second method. Use ssh -vv to inspect the actual authentication exchange.

Can I force a password without deleting or renaming my SSH keys?

Yes. The flags affect one invocation and do not modify keys or the SSH agent.

Does PasswordAuthentication=yes override the server?

No. It only controls the client's willingness to use password authentication. Server-side policy is separate.

Does this work in PowerShell?

Yes, with Windows OpenSSH Client installed. Replace grep in debugging examples with Select-String.

Can I enter the SSH password directly in the command?

The normal OpenSSH client has no --password option. Avoid embedding plaintext passwords in arguments, shell history or scripts.

Official documentation and community references

Bottom line: use the password-only client flags for a specific connection; verify what the client selected with ssh -G and what the server offered with ssh -vv. The server's authentication policy remains in control.

Why trust us
120+Published guides
30+Topics covered
View latest guides