summaryrefslogtreecommitdiffstats
path: root/roles/cgit/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/cgit/tasks/main.yml')
-rw-r--r--roles/cgit/tasks/main.yml29
1 files changed, 22 insertions, 7 deletions
diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml
index 7828042a..16a9ab61 100644
--- a/roles/cgit/tasks/main.yml
+++ b/roles/cgit/tasks/main.yml
@@ -32,23 +32,38 @@
scope: system
value: main
-- name: "Create git user .ssh directory"
+- name: "Ensure sshd_config restricts login to expected users"
become: true
- ansible.builtin.file:
- path: "{{ cgit_repos_dir }}/.ssh"
- state: directory
- owner: "{{ cgit_ssh_user }}"
- group: "{{ cgit_ssh_user }}"
- mode: "0700"
+ ansible.builtin.lineinfile:
+ path: "/etc/ssh/sshd_config"
+ regexp: "^AllowUsers "
+ line: "AllowUsers root {{ cgit_ssh_user }}"
+ validate: "sshd -T -f %s"
+ notify: "Restart sshd"
- name: "Deploy authorized_keys"
become: true
ansible.posix.authorized_key:
user: "{{ cgit_ssh_user }}"
key: "{{ item }}"
+ path: "/etc/ssh/authorized_keys/{{ cgit_ssh_user }}"
state: present
loop: "{{ user_public_keys }}"
+- name: "Configure sshd AuthorizedKeysFile for {{ cgit_ssh_user }}"
+ become: true
+ ansible.builtin.blockinfile:
+ path: "/etc/ssh/sshd_config"
+ marker: "# {mark} ANSIBLE {{ cgit_ssh_user }} MATCH BLOCK"
+ validate: "sshd -T -f %s"
+ block: |
+ Match User {{ cgit_ssh_user }}
+ AuthorizedKeysFile /etc/ssh/authorized_keys/%u
+ AllowTcpForwarding no
+ AllowAgentForwarding no
+ PermitTTY no
+ notify: "Restart sshd"
+
- name: "Create repos directory"
become: true
ansible.builtin.file: