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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. - name: Download Google authenticator pam module
  10. get_url: url=https://google-authenticator.googlecode.com/files/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
  11. dest=/root/libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
  12. - name: Extract Google authenticator
  13. command: tar xjf libpam-google-authenticator-{{ google_auth_version }}-source.tar.bz2
  14. chdir=/root creates=/root/libpam-google-authenticator-{{ google_auth_version }}
  15. - name: Install Google authenticator
  16. command: make install
  17. chdir=/root/libpam-google-authenticator-{{ google_auth_version }}
  18. creates=/usr/local/bin/google-authenticator
  19. - name: Update sshd config to enable challenge responses
  20. lineinfile: dest=/etc/ssh/sshd_config
  21. regexp=^ChallengeResponseAuthentication
  22. line="ChallengeResponseAuthentication yes"
  23. state=present
  24. notify: restart ssh
  25. - name: Add Google authenticator to PAM
  26. lineinfile: dest=/etc/pam.d/sshd
  27. line="auth required pam_google_authenticator.so"
  28. insertbefore=BOF
  29. state=present
  30. - name: Generate a timed-based, no reuse, rate-limited (3 logins per 30 seconds) with one concurrently valid code for default user
  31. 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
  32. creates=/home/{{ main_user_name }}/.google_authenticator
  33. sudo: yes
  34. sudo_user: "{{ main_user_name }}"
  35. when: ansible_ssh_user != "vagrant"
  36. - name: Retrieve generated keys from server
  37. fetch: src=/home/{{ main_user_name }}/.google_authenticator
  38. dest=/tmp/sovereign-google-auth-files
  39. when: ansible_ssh_user != "vagrant"
  40. - pause: seconds=5
  41. prompt="Your Google Authentication keys are in /tmp/sovereign-google-auth-files. Press any key to continue..."
  42. when: ansible_ssh_user != "vagrant"