Advertisement
Guest User

Untitled

a guest
Feb 20th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. ---
  2.  
  3. - name: configure a user
  4. hosts: all
  5. sudo: yes
  6. gather_facts: False
  7.  
  8. vars:
  9. # created with: openssl passwd -1 "baadal"
  10. baadal_password: $1$Ygfc1YR3$GV1GVKFZwSZiiHsa3DAo91
  11.  
  12. tasks:
  13.  
  14. - name: Add user baadal
  15. user: name=baadal password={{baadal_password}} shell=/bin/bash groups=root append=yes
  16.  
  17. - name: Add user baadal to sudoers
  18. lineinfile:
  19. "dest=/etc/sudoers
  20. regexp='^baadal ALL'
  21. line='baadal ALL=(ALL) NOPASSWD: ALL'
  22. state=present"
  23.  
  24. - name: Add SSH public key to user remote
  25. authorized_key:
  26. user=baadal
  27. key="{{ lookup('file', "../certs/nilesh.pub") }}"
  28.  
  29. - name: Disallow root SSH access
  30. lineinfile:
  31. dest=/etc/ssh/sshd_config
  32. regexp="^PermitRootLogin"
  33. line="PermitRootLogin no"
  34. state=present
  35. notify:
  36. - restart ssh
  37.  
  38. - name: Disallow SSH password authentication
  39. lineinfile:
  40. dest=/etc/ssh/sshd_config
  41. regexp="^PasswordAuthentication"
  42. line="PasswordAuthentication no"
  43. state=present
  44. notify:
  45. - restart ssh
  46.  
  47. - name: Disallow SSH GSS API authentication
  48. lineinfile:
  49. dest=/etc/ssh/sshd_config
  50. regexp="^GSSAPIAuthentication"
  51. line="GSSAPIAuthentication no"
  52. state=present
  53. notify:
  54. - restart ssh
  55.  
  56. handlers:
  57. - name: restart ssh
  58. service:
  59. name=ssh
  60. state=restarted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement