You can force your ssh client on a Linux, MacOS, FreeBSD, OpenBSD and Unix-like system to use only password authentication.
How to get prompted for password when I use pubkey auth?
The syntax is:
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no user@server
$ ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no firstname.lastname@example.org
$ ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no email@example.com
- PreferredAuthentications=password – The methods available for authentication are like GSSAPI-based authentication, host-based authentication, public key authentication, challenge response authentication, and password authentication. Authentication methods are tried in the order specified above, though PreferredAuthentications can be used to change the default order.
- PubkeyAuthentication=no – Disable public key authentication and force ssh to use password using PreferredAuthentications=password
Please note that you must have PasswordAuthentication yes set in server’s /etc/ssh/sshd_config file. If you want root user access set PermitRootLogin yes in server’s /etc/ssh/sshd_config file. Otherwise you will get an error that read as follows:
Permission denied (publickey,keyboard-interactive).
A note about why root over SSH is bad idea with or without password
It is dangerous enabling root login. The attacker or bots try to log in your server using brute force methods. They start with a simple password like “123456” and so on. They do this for an extended time to gain root access. With advancement in bandwidth and given resources the attacker or bots might end up getting root access to your server. I do not trust root or any other users to use password-based login as most users are at bad choosing passwords. Hence, I recommend that you do not enable password based login. See how to use public key based login for more info:
- How do I set up SSH public-key authentication to connect to a remote server
- How To set up SSH keys on a Linux server