您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

53 行
1.6 KiB

  1. ---
  2. - hosts: all
  3. # vars:
  4. # conf: /etc/ssh/sshd_config
  5. sudo: yes
  6. tasks:
  7. - name: find sshd_config
  8. set_fact: conf={{item}}
  9. with_first_found:
  10. - /etc/ssh/sshd_config
  11. - /etc/sshd_config
  12. - name: assert sshd_config found
  13. assert: conf is defined
  14. - name: Protocol 2
  15. lineinfile: dest={{conf}}
  16. regexp="^(#)?Protocol"
  17. line="Protocol 2"
  18. notify: restart sshd
  19. - name: PermitRootLogin no
  20. lineinfile: dest={{conf}}
  21. regexp="^(#)?PermitRootLogin"
  22. line="PermitRootLogin no"
  23. notify: restart sshd
  24. - name: RSAAuthentication no
  25. lineinfile: dest={{conf}}
  26. regexp="^(#)?RSAAuthentication"
  27. line="RSAAuthentication no"
  28. notify: restart sshd
  29. - name: PasswordAuthentication no
  30. lineinfile: dest={{conf}}
  31. regexp="^(#)?PasswordAuthentication"
  32. line="PasswordAuthentication no"
  33. notify: restart sshd
  34. - name: PermitEmptyPassword no
  35. lineinfile: dest={{conf}}
  36. regexp="^(#)?PermitEmptyPasswords"
  37. line="PermitEmptyPasswords no"
  38. notify: restart sshd
  39. - name: ChallengeResponseAuthentication no
  40. lineinfile: dest={{conf}}
  41. regexp="^(#)?ChallengeResponseAuthentication"
  42. line="ChallengeResponseAuthentication no"
  43. notify: restart sshd
  44. - name: UseDNS no
  45. lineinfile: dest={{conf}}
  46. regexp="^(#)?UseDNS"
  47. line="UseDNS no"
  48. notify: restart sshd
  49. handlers:
  50. - name: restart sshd
  51. service: name=ssh state=restarted