diff options
author | Halfwalker <deano-gitea@areyes.com> | 2024-12-21 18:41:43 -0700 |
---|---|---|
committer | Nicholas Johnson <mail@nicholasjohnson.ch> | 2025-01-29 00:00:00 +0000 |
commit | 40489e5b26bc741b15bbea5cf2ee634880d40384393bdc319d23c482b89a62c8 (patch) | |
tree | 3701e54b660fc89eded5541aab18cc94506d75cbc489ad17a3b9c4d06f3f2761 /tasks | |
parent | 9cdb5bbeaf8412b8931beb206431eb897fcfc6b40e02dd763d2d4068382550b5 (diff) | |
download | ansible-role-google-authenticator-40489e5b26bc741b15bbea5cf2ee634880d40384393bdc319d23c482b89a62c8.tar.gz ansible-role-google-authenticator-40489e5b26bc741b15bbea5cf2ee634880d40384393bdc319d23c482b89a62c8.zip |
Add option for nullok on google_authenticator.so in /etc/pam.d/sshd
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/main.yml | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tasks/main.yml b/tasks/main.yml index 882f8ad..3d47915 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -163,12 +163,27 @@ block: # Set pam to use google authenticator for ssh # echo "auth required pam_google_authenticator.so" >> /etc/pam.d/sshd + # echo "auth required pam_google_authenticator.so nullok" >> /etc/pam.d/sshd + # The nullok allows regular login if ~/.google_authenticator doesn't exist + # Putting at beginning of file means it will ask for token FIRST, then password + # This prevents someone from being able to attempt passwords until/unless they have token - name: Set pam to use google authenticator for ssh ansible.builtin.lineinfile: path: /etc/pam.d/sshd + insertafter: BOF + line: 'auth required pam_google_authenticator.so{% if google_auth_nullok %} nullok{% endif %}' + state: present + + # Must have at least one SUCCESS answer - nullok makes sshd answer IGNORE + # Adding pam_permit to end ensure that sshd module will answer SUCCESS if nothing else does + # https://github.com/google/google-authenticator-libpam#nullok + - name: Set pam to use pam_permit if nullok is defined + ansible.builtin.lineinfile: + path: /etc/pam.d/sshd insertafter: EOF - line: 'auth required pam_google_authenticator.so' + line: 'auth required pam_permit.so' state: present + when: google_auth_nullok - name: Modify sshd_config to use google authenticator ansible.builtin.copy: |