Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

If I use pubkey auth from e.g.: an Ubuntu 11.04 how can I set the ssh client to use only password auth to a server? (just needed because of testing passwords on a server, where I default log in with key)

I found a way:

mv ~/.ssh/id_rsa ~/.ssh/id_rsa.backup
mv ~/.ssh/ ~/.ssh/

and now I get prompted for password, but are there any offical ways?

share|improve this question

4 Answers 4

up vote 91 down vote accepted

I recently needed this too, and came up with this:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no
share|improve this answer
I needed to enforce the password prompt to appear in an environment where Kerberos was used for automated authentication, and a similar command worked for me in that specific situation: ssh -o GSSAPIAuthentication=no – IllvilJa Aug 13 '13 at 10:56

I've discovered a shortcut for this purpose:


Note the colon (:) and the empty password after it.

share|improve this answer
Very nice trick – Anthon Apr 13 '14 at 21:11
Is this documented somewhere? – Faheem Mitha Apr 13 '14 at 22:23
No documentation yet. Actually, I've skimmed through the OpenSSH source code to no avail (its parsing stage is rather cryptic and it's morning here :)). My initial motivation: many clients prompt for a password if you give an empty password, e.g. mysql -u user -p – Halil Özgür Apr 14 '14 at 2:38
I don't expect another answer will come up I like better, but I will leave the bounty open for a bit so this Q gets more attention. After reviewing this answer, I originally posted on the chat site to draw some attention to it, which got you some upvotes. But I hope the bounty gets you some more attention as well. – Anthon Apr 14 '14 at 11:51
@HalilÖzgür: Sad news, it was a lot easier to remember and to type ;) ! – WhiteWinterWolf Jun 13 at 12:53

As well as the method posted by scoopr, you can set per host options in your ssh client configuration file.

In your .ssh directory, create a file called config (if it doesn't already exist) and set the permissions to 600, you can then create sections which start with

host <some hostname or pattern>

and then set per host options after that, for example,

user fred

host *.home.example
user billy
port 9191

so you could have


in that file, and then simply


and the option will get picked up.

share|improve this answer

@scoopr and @Halil Özgür answers didn't work for me.

This worked for me:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no


share|improve this answer
The question is about client authentication by password. This answer is about checking if the servers host key matches one in known hosts. In effect it is answering a different question – Anigel Sep 3 at 10:48

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.