Skip to content

Commit f9dc018

Browse files
committed
add ssh_pubkey_authentication variable
Signed-off-by: debbabi <[email protected]>
1 parent bdf6d65 commit f9dc018

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: roles/ssh_hardening/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ If idempotency is important, please consider using role [`ssh-hardening-fallback
423423
- Description: Set to `false` to disable X11 Forwarding. Set to `true` to allow X11 Forwarding.
424424
- Type: bool
425425
- Required: no
426+
- `ssh_pubkey_authentication`
427+
- Default: `true`
428+
- Description: Set to `false` to disable publickey authentication.
429+
- Type: bool
430+
- Required: no
426431
- `sshd_authenticationmethods`
427432
- Default: `publickey`
428433
- Description: Specifies the authentication methods that must be successfully completed for a user to be granted access. Make sure to set all required variables for your selected authentication method. Defaults found in `defaults/main.yml`

Diff for: roles/ssh_hardening/defaults/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ ssh_x11_forwarding: false # sshd
9696
# false to disable pam authentication.
9797
ssh_use_pam: true # sshd
9898

99+
# false to disable publickey authentication
100+
ssh_pubkey_authentication: true
101+
99102
# specify AuthenticationMethods
100103
sshd_authenticationmethods: publickey
101104

Diff for: roles/ssh_hardening/templates/opensshd.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ MaxSessions {{ ssh_max_sessions }}
112112
MaxStartups {{ ssh_max_startups }}
113113

114114
# Enable public key authentication
115-
PubkeyAuthentication yes
115+
PubkeyAuthentication {{ 'yes' if (ssh_pubkey_authentication|bool) else 'no' }}
116116

117117
# Never use host-based authentication. It can be exploited.
118118
IgnoreRhosts yes

0 commit comments

Comments
 (0)