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

Commit 4d144a0

Browse files
committed
Moving over to using Ansible PAM support.
Using the Ansible PAM support rather than regex based line editing for two out of the three PAM changes required for 2FA support. The last change does not appear to be supported by the Ansible PAM support unless I have missed something from the documentation.
1 parent a821682 commit 4d144a0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tasks/main.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,20 @@
7373
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Oracle Linux'
7474

7575
- name: Add google auth module to PAM
76-
lineinfile: "dest=/etc/pam.d/sshd state=present insertbefore=BOF regexp='pam_google_authenticator.so$' line='auth required pam_google_authenticator.so'"
77-
notify: restart sshd
76+
pamd:
77+
name: sshd
78+
type: auth
79+
control: required
80+
module_path: pam_google_authenticator.so
81+
82+
- name: Remove password auth from PAM
83+
pamd:
84+
name: sshd
85+
type: auth
86+
control: substack
87+
module_path: password-auth
88+
state: absent
89+
when: ansible_distribution == 'RedHat' or ansible_distribution == 'Oracle Linux'
7890

7991
- name: Remove password auth from PAM
8092
replace:
@@ -83,13 +95,6 @@
8395
replace: '#@include common-auth'
8496
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
8597

86-
- name: Remove password auth from PAM
87-
replace:
88-
dest: /etc/pam.d/sshd
89-
regexp: '^auth substack password-auth'
90-
replace: '#auth substack password-auth'
91-
when: ansible_distribution == 'RedHat' or ansible_distribution == 'Oracle Linux'
92-
9398
when:
9499
- ssh_use_pam
95100
- ssh_challengeresponseauthentication

0 commit comments

Comments
 (0)