Ansible_workstation/tasks/ssh.yml

51 lines
1.1 KiB
YAML
Raw Normal View History

2018-08-24 08:00:59 +00:00
---
2020-03-17 04:44:48 +00:00
# - name: ssh -- Copy sshd_config
# template:
# src: files/sshd_config
# dest: /etc/ssh/sshd_config
2018-08-24 09:00:52 +00:00
2020-03-17 04:44:48 +00:00
- name: ssh -- Disable empty password login
2018-08-24 09:00:52 +00:00
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PermitEmptyPasswords"
line: "PermitEmptyPasswords no"
backrefs: yes
2018-11-07 09:57:55 +00:00
tags:
- first_deployement
2018-08-24 09:00:52 +00:00
2020-03-17 04:44:48 +00:00
- name: ssh -- Disable remote root login
2018-08-24 09:00:52 +00:00
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PermitRootLogin"
line: "PermitRootLogin no"
backrefs: yes
2018-11-07 09:57:55 +00:00
tags:
- first_deployement
2018-08-24 09:00:52 +00:00
2020-03-17 04:44:48 +00:00
- name: ssh -- Disable password login
2018-08-24 09:00:52 +00:00
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^#?PasswordAuthentication"
line: "PasswordAuthentication no"
backrefs: yes
2018-08-25 13:15:17 +00:00
when: add_identity_key is succeeded and not add_identity_key is skipped
2018-08-24 08:13:15 +00:00
notify: restart sshd
2018-11-07 09:57:55 +00:00
tags:
- first_deployement
2018-08-24 08:13:15 +00:00
2020-03-17 04:44:48 +00:00
- name: ssh -- Enable SSH daemon (not Debian)
2018-08-24 08:13:15 +00:00
service:
name: sshd
state: started
enabled: yes
2018-11-07 09:57:55 +00:00
tags:
- first_deployement
2019-02-06 19:18:37 +00:00
when: ansible_distribution != 'Debian'
2018-08-24 08:17:21 +00:00
2020-03-17 04:44:48 +00:00
- name: ssh -- Enable SSH daemon (Debian)
2019-02-06 19:18:37 +00:00
service:
name: ssh
state: started
enabled: yes
when: ansible_distribution == 'Debian'