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

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. tags:
  11. - dependencies
  12. - name: Update sshd config to enable challenge responses
  13. lineinfile: dest=/etc/ssh/sshd_config
  14. regexp=^ChallengeResponseAuthentication
  15. line="ChallengeResponseAuthentication yes"
  16. state=present
  17. notify: restart ssh
  18. - name: Add Google authenticator to PAM
  19. lineinfile: dest=/etc/pam.d/sshd
  20. line="auth required pam_google_authenticator.so"
  21. insertbefore=BOF
  22. state=present
  23. - name: Generate a timed-based, no reuse, rate-limited (3 logins per 30 seconds) with one concurrently valid code for default user
  24. 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
  25. creates=/home/{{ main_user_name }}/.google_authenticator
  26. sudo: yes
  27. sudo_user: "{{ main_user_name }}"
  28. when: ansible_ssh_user != "vagrant"
  29. - name: Retrieve generated keys from server
  30. fetch: src=/home/{{ main_user_name }}/.google_authenticator
  31. dest=/tmp/sovereign-google-auth-files
  32. when: ansible_ssh_user != "vagrant"
  33. - pause: seconds=5
  34. prompt="Your Google Authentication keys are in /tmp/sovereign-google-auth-files. Press any key to continue..."
  35. when: ansible_ssh_user != "vagrant"