Roots Discourse

Provisioning using a ssh config file

Since we share the .PEM key (they are stored in our company’s 1password account) across several computers, I’d like to use an .ssh configuration file.

I therefore created 1 per server. Here is one :

  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/GITHUB/projects/

then in  `users.yml` I added a pointer to the ssh config file.

  - name: "{{ web_user }}"
      - "{{ web_group }}"
      - "{{ lookup('file', '~/.ssh/') }}"

  - name: "{{ admin_user }}"
      - sudo
      - "{{ lookup('file', '~/.ssh/') }}"

It sort of works: I can provision the server. But then the TASK [users : Add SSH keys] fails

invalid key specified: Host

I assume Ansible mistakenly uses the config file for the public key file ? Is there a reasonable way to achieve using ssh config files instead of public keys in users.yml ?

Yeah unfortunately you’re correct and it’s just the public key. That uses Ansible’s authorized_key module which only does that. There’s no built-in way to manager SSH configs I think…

Only custom solution I found:

This topic was automatically closed after 42 days. New replies are no longer allowed.