No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

google_auth_mod.yml 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ---
  2. # Defines tasks applicable for Google Authenticator
  3. # Ubuntu trusty version, uses standard libpam-google-authenticator package
  4. - name: Ensure required packages are installed
  5. apt: pkg={{ item }} state=present
  6. with_items:
  7. - libpam-google-authenticator
  8. - libpam0g-dev
  9. - libqrencode3
  10. - name: Update sshd config to enable challenge responses
  11. lineinfile: dest=/etc/ssh/sshd_config
  12. regexp=^ChallengeResponseAuthentication
  13. line="ChallengeResponseAuthentication yes"
  14. state=present
  15. notify: restart ssh
  16. - name: Add Google authenticator to PAM
  17. lineinfile: dest=/etc/pam.d/sshd
  18. line="auth required pam_google_authenticator.so"
  19. insertbefore=BOF
  20. state=present
  21. - name: Generate a timed-based, no reuse, rate-limited (3 logins per 30 seconds) with one concurrently valid code for default user
  22. command: /usr/bin/google-authenticator -t -f -d --label="{{ main_user_name }}@{{ domain }}" --qr-mode=ANSI -r 3 -R 30 -w 1 --secret=/home/{{ main_user_name }}/.google_authenticator
  23. creates=/home/{{ main_user_name }}/.google_authenticator
  24. sudo: yes
  25. sudo_user: "{{ main_user_name }}"
  26. when: ansible_ssh_user != "vagrant"
  27. - name: Retrieve generated keys from server
  28. fetch: src=/home/{{ main_user_name }}/.google_authenticator
  29. dest=/tmp/sovereign-google-auth-files
  30. when: ansible_ssh_user != "vagrant"
  31. - pause: seconds=5
  32. prompt="Your Google Authentication keys are in /tmp/sovereign-google-auth-files. Press any key to continue..."
  33. when: ansible_ssh_user != "vagrant"