0
0
vps-set-up-playbook/roles/ssh/tasks/main.yaml

37 lines
854 B
YAML
Raw Normal View History

2023-11-11 02:06:42 +08:00
- 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
2023-11-25 08:10:49 +08:00
enabled: true
2023-11-11 02:06:42 +08:00
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/*
2023-11-25 08:10:49 +08:00
# ls -al .ssh