0
0
vps-set-up-playbook/roles/ssh/tasks/main.yaml
2023-12-15 04:54:22 +08:00

37 lines
854 B
YAML

- name: Copy SSH config
template:
src: sshd.conf.j2
dest: /etc/ssh/sshd_config.d/sshd.conf
owner: 0
group: 0
mode: 0600
# ----------------------------------------------------------------------------------------------------------------
- name: Restart SSH service
systemd:
name: sshd
enabled: true
state: restarted
# ----------------------------------------------------------------------------------------------------------------
- name: Create .ssh directory if it doesn't exist
file:
path: "/home/{{ user }}/.ssh"
state: directory
mode: '0700'
owner: "1000"
group: "1000"
- name: Set permissions for authorized_keys
file:
path: "{{ ansible_env.HOME }}/.ssh/authorized_keys"
state: touch
mode: '0600'
owner: "1000"
group: "1000"
# stat -c "%a %n" .ssh/*
# ls -al .ssh