How do I force SSH to use password instead of key?

So I need to log in to a machine using a password instead of a key, which I practically never do. Seems it should be easy but nope, ssh refuses to use anything but a key.

ssh -o PreferredAuthentications=keyboard-interactive -o PubkeyAuthentication=no root@ip-address
root@ip-address: Permission denied (publickey).
1

5 Answers

You try using correct parameters for disabling authentication over keys. Maybe server reject password authentication? Check server ssh configuration.

2
Permission denied (publickey)

The "(publickey)" string in that error message is the list of authentication methods accepted by the remote server. In this case the remote server only accepts public key authentication. You can change your client parameters all you like, but it won't alter the fact that the server will only accept public key authentication.

To log in with a password, you'd have to start by reconfiguring the remote server to accept password authentication.

Turns out the solution was to set PasswordAuthentication yes in /etc/ssh/sshd_config.

Thanks to the several people who pointed me in the right direction.

root@ip-address: Permission denied (publickey)

This message means your server only allow publickey, thus please enable password auth in /etc/sshd_config with:

Password Authentication yes

It is possible your system allow password but not keyboard-interaction, like

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

In this case, you need to use following instead:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no 

To use password authentication instead of a key, SSH must allow passwords. Inside of /etc/ssh/sshd_config Change the PasswordAuthentication option from no to yes (Note this is bad practice):

PasswordAuthentication yes

Because your example shows the user as root, you must also allow root to login via a password. (Note this is bad practice)

PermitRootLogin yes

Restart ssh for the setting to take effect:

systemctl restart sshd

Now, you can specify you desire ssh when connecting via CLI rather than permanently with config files:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -o PasswordAuthentication=yes root@ip-address

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like