摘要

用于向远程主机的某个账户的authorized_keys文件中增加公钥 或 从中移除公钥。


选项


例子

- authorized_key: user=charlie key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
- authorized_key: user=charlie key=https://github.com/charlie.keys
- authorized_key:
    user: charlie
    key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
    path: '/etc/ssh/authorized_keys/charlie'
    manage_dir: no
- name: Set up authorized_keys for the deploy user
  authorized_key: user=deploy key="{{ item }}"
  with_file:
    - public_keys/doe-jane
    - public_keys/doe-john
- authorized_key:
    user: charlie
    key:  "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
    key_options: 'no-port-forwarding,from="10.0.1.1"'
- authorized_key: user=charlie key=https://github.com/user.keys validate_certs=no
- authorized_key: user=root key="{{ item }}" state=present exclusive=yes
  with_file:
    - public_keys/doe-jane
- authorized_key: user=ubuntu key="{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
  become: yes