Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to temporarily disable public key authentication when ssh'ing, and use password authentication instead?

I currently want to access remote server, but I'm using another laptop, not mine.

Browsing that link, I found that the command ssh -o PreferredAuthentications=keyboard-interactive -o PubkeyAuthentication=no doesn't work everywhere. And yes, it doesn't work for me. I'm using: OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012

Edit: I also tried to type ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no but still have "Permission denied (publickey)".

So, is there a specific configuration to do in the remote server, for that command to work? Or, when that command will work as expected?

Thanks a lot for advices.

share|improve this question
If you followed the link again, there was someone stating that your method didn't work, but this did: ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no – NickW Mar 28 '13 at 15:03
@NikW Thanks a lot, maybe I should have mention it, tried the command you propose too, still have the "Permission denied (publickey)". – Nsukami _ Mar 28 '13 at 22:41
I am doing fine. Thanks for asking. – mgalgs Apr 14 '14 at 23:03
Just hit this problem because my laptop had a TON of keys, and ssh tried all of them, and I was rejected before even a chance to enter password. Thanks for asking. – Dallaylaen Dec 21 '15 at 15:55
@NickW If you put your comment as the answer, I'd upvote it. – labyrinth Jan 6 at 22:22
up vote 5 down vote accepted

This sounds like a configuration issue on the server side.

If the server allows both public key and password authentication then even if you try to connect without a private key file present on the client, it should prompt you for a password.

If you are getting the error message "Permission denied (publickey)" then it sounds like password authentication is not supported on your server.

Without seeing the /etc/sshd_config file, it is difficult to know but my guess would be that you need to make sure the following line exists:

PasswordAuthentication yes

Restart the ssh server, and when you connect from the client you should be prompted for a password if there is no private key present, or if the private key doesn't match the public key on the server.

A more secure alternative to this of course would be to copy your private key to the laptop which you are using, or in-fact generate a new private key to be used on that laptop and add the public key to .ssh/authorized_keys

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.