How to force ssh client to use only password auth?

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

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com

You need to make sure that the client isn't configured to disallow password authentication.


I've discovered a shortcut for this purpose:

ssh user:@example.com

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


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
PubkeyAuthentication no

in that file, and then simply

ssh server.to.test

and the option will get picked up.