Take the 2-minute tour ×
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/id_rsa.pub ~/.ssh/id_rsa.pub.backup

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

share|improve this question

4 Answers 4

up vote 51 down vote accepted

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

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com
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 example.com –  IllvilJa Aug 13 '13 at 10:56

I've discovered a shortcut for this purpose:

ssh user:@example.com

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
Thanks. I hope that this is not very fragile and meets the expectations. By the way, the question Why doesn't the ssh command follow RFC on URI? and the answers there seem relevant. I guess the modus operandi here is that OpenSSH sees the empty password, having discovered that the remote sshd doesn't allow empty passwords, prompts the user for one, or something like that. I'm hoping to take another shot at the source code when I have some time. –  Halil Özgür Apr 14 '14 at 13:25

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,

host bob.specific.foo
user fred

host *.home.example
user billy
port 9191

so you could have

host server.to.test

in that file, and then simply

ssh server.to.test

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 user@example.com

Source: http://linuxcommando.blogspot.com/2008/10/how-to-disable-ssh-host-key-checking.html

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.