ansible批量修改sshd_config

简介:
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

本文转自激情燃烧的岁月博客51CTO博客,原文链接http://blog.51cto.com/liuzhengwei521/1966503如需转载请自行联系原作者

weilovepan520
相关文章
|
安全 Linux 网络安全
SSH远程登陆配置sshd_config文件详解
ssh是linux远程登录的安全协议,是 C/S 模式的架构,配置文件分为服务器端配置文件 [/etc/ssh/sshd_config] 与客户端配置文件默认配置文件[/etc/ssh/ssh_config] 用户配置文件[~/.ssh/config] sshd_config 是服务端主配置文件。
|
网络安全 网络协议
[20180504]检查sshd配置是否正确.txt
[20180504]检查sshd配置是否正确.txt --//有时候要修改sshd配置文件,有可能改错,如果这个时候远程重启sshd,可能导致无法再远程登录, --//必须有一种机制在重启前检查sshd的配置是否正确.
1516 0
|
Shell 数据安全/隐私保护 网络安全
Ansible批量修改root密码(playbook)
1、vi changpass.yml hosts: lqtapi gather_facts: false tasks: name: chattr -i shell: chattr -i /etc/shadow name: copy ssh key...
2452 0
|
数据安全/隐私保护 网络安全
Ansible设置root免密码登录
1、控制机上执行:ssh-keygen 2、一路回车 3、vi rsync_key.yml hosts: all gather_facts: false tasks: name: copy ssh key authorized_key: user: root key: "{{ lookup('file', '/root/.
1132 0
|
网络安全 数据安全/隐私保护 开发工具
|
网络安全 数据安全/隐私保护
|
应用服务中间件 nginx 数据安全/隐私保护