Browse Source

Automatically generate the Google authenticator file for the default user

Justin Plock 10 years ago
parent
commit
22a8717f6d
No account linked to committer's email address
2 changed files with 30 additions and 6 deletions
  1. 29
    5
      roles/common/tasks/google_auth.yml
  2. 1
    1
      roles/common/tasks/main.yml

+ 29
- 5
roles/common/tasks/google_auth.yml View File

9
     #- libpam-google-authenticator    wasn't available in wheezy
9
     #- libpam-google-authenticator    wasn't available in wheezy
10
 
10
 
11
 - name: Download Google authenticator pam module
11
 - name: Download Google authenticator pam module
12
-  get_url: url=https://google-authenticator.googlecode.com/files/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2 dest=/root/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
12
+  get_url: url=https://google-authenticator.googlecode.com/files/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
13
+           dest=/root/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
13
 
14
 
14
 - name: Extract Google authenticator
15
 - name: Extract Google authenticator
15
-  command: tar xjf libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2 chdir=/root creates=/root/libpam-google-authenticator-{{ google_auth_version }}
16
+  command: tar xjf libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
17
+           chdir=/root creates=/root/libpam-google-authenticator-{{ google_auth_version }}
16
 
18
 
17
 - name: Install Google authenticator
19
 - name: Install Google authenticator
18
-  command: make install chdir=/root/libpam-google-authenticator-{{ google_auth_version }} creates=/usr/local/bin/google-authenticator
20
+  command: make install
21
+           chdir=/root/libpam-google-authenticator-{{ google_auth_version }}
22
+           creates=/usr/local/bin/google-authenticator
19
 
23
 
20
 - name: Update sshd config to enable challenge responses
24
 - name: Update sshd config to enable challenge responses
21
-  lineinfile: dest=/etc/ssh/sshd_config regexp=^ChallengeResponseAuthentication line="ChallengeResponseAuthentication yes" state=present
25
+  lineinfile: dest=/etc/ssh/sshd_config
26
+              regexp=^ChallengeResponseAuthentication
27
+              line="ChallengeResponseAuthentication yes"
28
+              state=present
22
   notify: restart ssh
29
   notify: restart ssh
23
 
30
 
24
 - name: Add Google authenticator to PAM
31
 - name: Add Google authenticator to PAM
25
-  lineinfile: dest=/etc/pam.d/sshd line="auth required pam_google_authenticator.so" insertbefore=BOF state=present
32
+  lineinfile: dest=/etc/pam.d/sshd
33
+              line="auth required pam_google_authenticator.so"
34
+              insertbefore=BOF
35
+              state=present
36
+
37
+- name: Generate QNR code for default user
38
+  command: /usr/local/bin/google-authenticator -t -f -d --label="{{ main_user_name }}@{{ domain }}" --qr-mode=ANSI -r 3 -R 30 -W --secret=/home/{{ main_user_name }}/.google_authenticator
39
+           creates=/home/{{ main_user_name }}/.google_authenticator
40
+
41
+- name: Fix permissions on generated file
42
+  file: state=file path=/home/{{ main_user_name }}/.google_authenticator owner={{ main_user_name }} group={{ main_user_name }}
43
+
44
+- name: Retrieve generated keys from server
45
+  fetch: src=/home/{{ main_user_name }}/.google_authenticator
46
+         dest=/tmp/sovereign-google-auth-files
47
+
48
+- pause: seconds=5
49
+         prompt="Your Google Authentication keys are in /tmp/sovereign-google-auth-files. Press any key to continue..."

+ 1
- 1
roles/common/tasks/main.yml View File

48
   notify: restart apache
48
   notify: restart apache
49
 
49
 
50
 - include: encfs.yml tags=encfs
50
 - include: encfs.yml tags=encfs
51
-- include: google_auth.yml tags=google_auth
52
 - include: users.yml tags=users
51
 - include: users.yml tags=users
53
 - include: ssl.yml tags=ssl
52
 - include: ssl.yml tags=ssl
54
 - include: ufw.yml tags=ufw
53
 - include: ufw.yml tags=ufw
55
 - include: security.yml tags=security
54
 - include: security.yml tags=security
56
 - include: ntp.yml tags=ntp
55
 - include: ntp.yml tags=ntp
56
+- include: google_auth.yml tags=google_auth

Loading…
Cancel
Save