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

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