Disabling password-based authentication totally in favor of the key-based one…
- User
Disabling password-based authentication totally in favor of the key-based one Restricting password-based authentication to specific groups
- Assistant
It looks like you want to manage SSH authentication settings, specifically:
- Disabling password-based authentication entirely to enforce key-based authentication only.
- Restricting password-based authentication so that only specific user groups can authenticate using passwords, while others must use keys.
1. Disabling Password-Based Authentication Entirely (Enforce Key-Based Only)
To disable password-based authentication over SSH so that only key-based authentication is allowed:
-
Edit the SSH server config file:
bashsudo nano /etc/ssh/sshd_config -
Find and modify/set these parameters:
bashPasswordAuthentication no ChallengeResponseAuthentication no UsePAM no -
Ensure public key authentication is enabled:
bashPubkeyAuthentication yes -
Restart SSH service to apply changes:
bashsudo systemctl restart sshd
2. Restrict Password Authentication to Specific Groups Only
SSH daemon’s default config
sshd_configdoes not directly support conditional authentication modes per user or group. But you can achieve this by leveraging:- UsePAM yes (enable Pluggable Authentication Module support)
- PAM configuration that restricts password authentication to certain groups.
- SSH's
Matchblocks to change certain options based on users or groups.
Approach Using
MatchBlocks and PAM:-
Enable PAM in sshd_config:
bashUsePAM yes PasswordAuthentication yes -
Use a
Matchblock to disable password authentication for everyone except a specific group:
Example, only users in the group
passworduserscan use passwords, others must use keys only.bash