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

35 lines
835 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
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