How to upload ssh public key to as authorized_key using Ansible

w‮w‬w.lautturi.com
How to upload ssh public key to as authorized_key using Ansible

To upload an ssh public key as an authorized_key using Ansible, you can use the authorized_key module. This module allows you to manage ssh public keys for remote users.

Here's an example playbook that demonstrates how to use the authorized_key module to upload a public key as an authorized_key:

---
- hosts: all
  tasks:
  - name: Add ssh public key to authorized_keys
    authorized_key:
      user: username
      key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYi3qIj1pZOdDODLxTpT7vgFyPcjKPQoZfX4c1mbGZKj0YwI1dFc/L/N2KiRcRZMct/9f9XZ3/qY/AEiSvGvSbxA4y7TtJnT4G2C4c9XsZs1nZsjwvQPWAlr8D5yVu0yGv0ZVJp9B+DFZVYMZ0bwO6h5e6UIR3yO+z1scvJ1Wrd9hD5Q5R5O5hb/O5/Fx3U6/gU6CvN1hEu8/5D5Q5R5O5hb/O5/Fx3U6/gU6CvN1hEu8/5D5Q5R5O5hb/O5/Fx3U6/gU6CvN1hEu8/5D5Q5R5O5hb/O5/Fx3U6/gU6CvN1hEu8/5D5Q5R5O5hb/O5/Fx3U6/gU6CvN1hEu8/5D5Q5R5O5hb/O5/Fx3U6/gU6CvN1hEu8/5D5Q5R5
Created Time:2017-10-29 22:08:40  Author:lautturi