backup_base: Add sftp ssh config when needed

This commit is contained in:
Timo Makinen 2024-06-22 19:09:20 +00:00
parent e233860b7b
commit 788c9fa453

View file

@ -30,3 +30,25 @@
owner: root
group: "{{ ansible_wheel }}"
follow: false
- name: Create authorized_keys
ansible.builtin.copy:
dest: /etc/ssh/authorized_keys.backup
src: ../files/ssh/backup.pub
mode: "0640"
owner: root
group: backup
when: "'sftpbackup' in group_names"
- name: Configure sshd chroot
ansible.builtin.blockinfile:
path: /etc/ssh/sshd_config
block: |
Match User backup
ChrootDirectory /srv/backup
ForceCommand internal-sftp
AuthorizedKeysFile /etc/ssh/authorized_keys.backup
marker: "# {mark} ANSIBLE MANAGED BLOCK (user backup)"
validate: "sshd -t -f %s"
when: "'sftpbackup' in group_names"
notify: Restart sshd