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.yml 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. # Defines tasks applicable for Google Authenticator
  3. - name: Ensure required packages are installed
  4. apt: pkg={{ item }} state=present
  5. with_items:
  6. #- libpam-google-authenticator wasn't available in wheezy
  7. - libpam0g-dev
  8. - libqrencode3
  9. tags:
  10. - dependencies
  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
  13. dest=/root/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
  14. - name: Extract Google authenticator
  15. unarchive: src=/root/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
  16. creates=/root/libpam-google-authenticator-{{ google_auth_version }}
  17. dest=/root copy=no
  18. - name: Install Google authenticator
  19. command: make install
  20. chdir=/root/libpam-google-authenticator-{{ google_auth_version }}
  21. creates=/usr/local/bin/google-authenticator
  22. - name: Update sshd config to enable challenge responses
  23. lineinfile: dest=/etc/ssh/sshd_config
  24. regexp=^ChallengeResponseAuthentication
  25. line="ChallengeResponseAuthentication yes"
  26. state=present
  27. notify: restart ssh
  28. - name: Add Google authenticator to PAM
  29. lineinfile: dest=/etc/pam.d/sshd
  30. line="auth required pam_google_authenticator.so"
  31. insertbefore=BOF
  32. state=present
  33. - name: Generate a timed-based, no reuse, rate-limited (3 logins per 30 seconds) with one concurrently valid code for default user
  34. command: /usr/local/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
  35. creates=/home/{{ main_user_name }}/.google_authenticator
  36. sudo: yes
  37. sudo_user: "{{ main_user_name }}"
  38. when: ansible_ssh_user != "vagrant"
  39. - name: Retrieve generated keys from server
  40. fetch: src=/home/{{ main_user_name }}/.google_authenticator
  41. dest=/tmp/sovereign-google-auth-files
  42. when: ansible_ssh_user != "vagrant"
  43. - pause: seconds=5
  44. prompt="Your Google Authentication keys are in /tmp/sovereign-google-auth-files. Press any key to continue..."
  45. when: ansible_ssh_user != "vagrant"