dotfiles/playbooks/roles/ssh/tasks/main.yml
Matej Focko 78eaf7ec02
feat(ssh): do not recreate key if exists
Fixes #37

Signed-off-by: Matej Focko <mfocko@redhat.com>
2022-03-12 23:25:23 +01:00

24 lines
472 B
YAML

---
- name: Check if SSH key exists
stat:
path: ~/.ssh/id_ed25519
register: ssh_key
- name: Generate SSH key
user:
name: mfocko
generate_ssh_key: yes
ssh_key_type: ed25519
ssh_key_comment: "$HOSTNAME-{{ ansible_facts['distribution'] }}"
when: not ssh_key.stat.exists
- name: Install SSH config
template:
src: templates/ssh_config.j2
dest: ~/.ssh/config
mode: 0600
- name: Enable sshd
systemd:
name: sshd
enabled: yes