dotfiles-ansible/roles/config/tasks/ssh.yml

29 lines
742 B
YAML

---
- name: ssh | Ensure 0700 permission on ~/.ssh directory
file:
path: ~/.ssh
mode: 0700
state: directory
- name: ssh | Configure OpenSSH client
block:
- name: ssh | Create config file if it doesn't exists
file:
path: ~/.ssh/config
mode: 0600
state: touch
# Use blockinfile instead of lineinfile to have nice space
# between config section
- name: ssh | Configure OpenSSH to accept new host keys
blockinfile:
path: ~/.ssh/config
block: |
AddKeysToAgent no
StrictHostKeyChecking accept-new
insertbefore: BOF
marker: '# {mark} CUSTOM SSH CONFIG'
state: present
mode: 0600
when: ssh_client == 'openssh'