Skip to content
Snippets Groups Projects
Commit d47405fc authored by hofmann's avatar hofmann :speech_balloon:
Browse files

finish tasks and structuring

parent 773d04a1
No related branches found
No related tags found
No related merge requests found
---
- hosts:
become: true
roles:
- configure_pam
- configure_sshd_conf
- install_googleauth
\ No newline at end of file
UsePAM yes
Challenge ResponseAuthentication yes
PermitRootLogin yes
AuthenticationMethods publickey,keyboard-interactive
\ No newline at end of file
---
- name: insert lines in /etc/pam.d/sshd
blockinfile:
path: /etc/pam.d/sshd
block: |
# two-factor authentication via Google Authenticator
auth required pam_google_authenticator.so no_increment_hotp nullok
- name: restart ssh
service:
name: ssh
state: restarted
\ No newline at end of file
---
- name: check if sshd_config.d directory exists
stat:
path: "{{ item }}"
register: folder_stats
with_items:
- ["/etc/ssh/sshd_config.d"]
- name: insert lines if directory doesn't exists
with_items: "{{ folder_stats.results }}"
lineinfile:
path: /etc/ssh/sshd_config
state: present
line: "AllowUsers slub root \n AllowGroups ssh"
when: item.stat.exists == false
- name: create extra sshd_config
with_items: "{{ folder_stats.results }}"
template:
src: ./files/sshd_config
dest: /etc/ssh/sshd_config.d/sshd.config
owner: root
group: root
mode: '0644'
when: item.stat.exists == true
- name: restart ssh
service:
name: ssh
state: restarted
\ No newline at end of file
---
- name: Install google_authenticator
package:
name: libpam-google-authenticator
state: present
\ No newline at end of file
---
- import_tasks: "configure_pam.yml"
- import_tasks: "configure_sshd_conf.yml"
- import_tasks: "install_googleauth.yml"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment