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
For example:
$ ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no vivek@server1.cyberciti.biz
$ ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no root@ln.db1
Sample outputs:
Fig.01: How to force openssh client to use only password auth
- 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
ssh root@mordor ?
- 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
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |