Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit a5a1886

Browse files
authored
Merge pull request #245 from szEvEz/refactor-authentication-methods
refactor authenticationmethod settings, allow user to set authenticat…
2 parents b6f947c + 686972f commit a5a1886

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Warning: This role disables root-login on the target server! Please make sure yo
5454
|`ssh_challengeresponseauthentication` | false | Specifies whether challenge-response authentication is allowed (e.g. via PAM) |
5555
|`ssh_client_password_login` | false | `true` to allow password-based authentication with the ssh client |
5656
|`ssh_server_password_login` | false | `true` to allow password-based authentication with the ssh server |
57-
|`ssh_google_auth` | false | `true` to enable google authenticator based TOTP 2FA |
58-
|`ssh_pam_device` | false | `true` to enable public key auth with pam device 2FA |
5957
|`ssh_banner` | `false` | `true` to print a banner on login |
6058
|`ssh_client_hardening` | `true` | `false` to stop harden the client |
6159
|`ssh_client_port` | `'22'` | Specifies the port number to connect on the remote host. |
@@ -79,6 +77,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
7977
|`sshd_syslog_facility` | 'AUTH' | The facility code that is used when logging messages from sshd |
8078
|`sshd_log_level` | 'VERBOSE' | the verbosity level that is used when logging messages from sshd |
8179
|`sshd_strict_modes` | 'yes' | Check file modes and ownership of the user's files and home directory before accepting login |
80+
|`sshd_authenticationmethods` | `publickey` | 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`
8281

8382
## Configuring settings not listed in role-variables
8483

defaults/main.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ ssh_pam_support: true
6767
# false to disable pam authentication.
6868
ssh_use_pam: true # sshd
6969

70-
# false to disable google 2fa authentication
71-
ssh_google_auth: false # sshd
72-
73-
# false to disable pam device 2FA input
74-
ssh_pam_device: false # sshd
70+
# specify AuthenticationMethods
71+
sshd_authenticationmethods: 'publickey'
7572

7673
# true if SSH support GSSAPI
7774
ssh_gssapi_support: false

tasks/hardening.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
when:
7070
- ssh_use_pam | bool
7171
- ssh_challengeresponseauthentication | bool
72-
- ssh_google_auth | bool
7372

7473
- name: include selinux specific tasks
7574
include_tasks: selinux.yml

templates/opensshd.conf.j2

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,11 @@ HostbasedAuthentication no
107107
{% if ssh_pam_support -%}
108108
UsePAM {{ 'yes' if (ssh_use_pam|bool) else 'no' }}
109109
{% endif %}
110-
{% if ssh_google_auth %}
111-
# Force public key auth then ask for google auth code
112-
AuthenticationMethods publickey,keyboard-interactive
113-
{% endif %}
114110

115-
# Force public key auth then ask for pam device input
116-
{% if ssh_pam_device %}
117-
AuthenticationMethods publickey,keyboard-interactive:pam
111+
# Set AuthenticationMethods per default to publickey
112+
# AuthenticationMethods was introduced in OpenSSH 6.2 - https://www.openssh.com/txt/release-6.2
113+
{% if sshd_version.stdout is version('6.2', '>=') %}
114+
AuthenticationMethods {{ sshd_authenticationmethods }}
118115
{% endif %}
119116

120117
# Disable password-based authentication, it can allow for potentially easier brute-force attacks.

0 commit comments

Comments
 (0)