Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ssh_pubkey_authentication variable to ssh hardening #749

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions roles/ssh_hardening/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ If idempotency is important, please consider using role [`ssh-hardening-fallback
- Description: Set to `false` to disable X11 Forwarding. Set to `true` to allow X11 Forwarding.
- Type: bool
- Required: no
- `ssh_pubkey_authentication`
- Default: `true`
- Description: Set to `false` to disable publickey authentication.
- Type: bool
- Required: no
- `sshd_authenticationmethods`
- Default: `publickey`
- 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`
Expand Down
3 changes: 3 additions & 0 deletions roles/ssh_hardening/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ ssh_x11_forwarding: false # sshd
# false to disable pam authentication.
ssh_use_pam: true # sshd

# false to disable publickey authentication
ssh_pubkey_authentication: true

# specify AuthenticationMethods
sshd_authenticationmethods: publickey

Expand Down
2 changes: 1 addition & 1 deletion roles/ssh_hardening/templates/opensshd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ MaxSessions {{ ssh_max_sessions }}
MaxStartups {{ ssh_max_startups }}

# Enable public key authentication
PubkeyAuthentication yes
PubkeyAuthentication {{ 'yes' if (ssh_pubkey_authentication|bool) else 'no' }}

# Never use host-based authentication. It can be exploited.
IgnoreRhosts yes
Expand Down