소스 검색

Automatically generate the Google authenticator file for the default user

Justin Plock 10 년 전
부모
커밋
22a8717f6d
No account linked to committer's email address
2개의 변경된 파일30개의 추가작업 그리고 6개의 파일을 삭제
  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 파일 보기

@@ -9,17 +9,41 @@
9 9
     #- libpam-google-authenticator    wasn't available in wheezy
10 10
 
11 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 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 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 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 29
   notify: restart ssh
23 30
 
24 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 파일 보기

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

Loading…
취소
저장