Reverting to passworded SSH (root) logins

My normal ssh logins are with public keys authentication (aka passwordless), however, under certain circumstances I’d like to revert back to good old passwords logins. Like when I want to transfer a Plesk server across another server using the Plesk Migration & Transfer manager.

After scouring the Net for some inspiration, which failed, and some tinkering, I finally found a neat solution to switch between the two (passwordless and normal authentication logins) quickly, the process is relatively simple* but frankly puzzling IMHO. I shall explain why:

By default, most sshd_config files state:

#PermitRootLogin yes

Which is meant to be the “default” because it is commented out. This line matters little when PKI is in use. However it seems that it is not the case [the default being “yes” as it is commented out] as if I specifically uncomment the line:

PermitRootLogin yes

…and restart the sshd service, I can login the server with the following command:

ssh -o PubkeyAuthentication=no root@host

If the line is “defaulted” (with a#). I am unsuccessful :-(

Plesk Migration (or other applications requiring password ssh)

So, when an application like the Plesk Migration & Transfer Manager requires a ssh username/password pair, under the current [passwordless] set up just edit the sshd_config file to change the following:

PubkeyAuthentication yes

to:

PubkeyAuthentication no

restart sshd afterwards and you’re good.

*This set up is on a centos 6 64