1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
---
- hosts: all
gather_facts:
true
remote_user: root
tasks:
- name:
"修改ssh配置文件的安全选项"
lineinfile:
path:
/etc/ssh/sshd_config
regexp:
'{{ item.regexp }}'
line:
'{{ item.line }}'
state: present
with_items:
- regexp:
"^PasswordAuthentication"
line:
"PasswordAuthentication no"
- regexp:
"^#PermitRootLogin yes"
line:
"PermitRootLogin no"
- regexp:
"^#Port 22"
line:
"Port 2249"
- regexp:
"^GSSAPIAuthentication yes"
line:
"GSSAPIAuthentication no"
notify:
- restart sshd
handlers:
- name: restart sshd
service:
name: sshd
state: restarted
|
weilovepan520