Commit 58abaaca authored by Nguyễn Văn Vũ's avatar Nguyễn Văn Vũ

Week3 - Configure Security Standards for Ubuntu by Ansible Script And...

Week3 - Configure Security Standards for Ubuntu by Ansible Script And Configure ssh access on remote host
parent 4fbc998a
---
- name: Generate SSH key pair and configure SSH access
hosts: your_remote_host
vars:
username_host_remote: "ansible"
become: yes
tasks:
- name: Generate SSH key pair
ansible.builtin.openssh_keypair:
path: "/home/{{ username_host_remote }}/.ssh/id_rsa"
owner: { { username_host_remote } }
- name: Add SSH public key to authorized_keys
ansible.builtin.authorized_key:
user: { { username_host_remote } }
key: "{{ lookup('file', '/home/{{ username_host_remote }}/.ssh/id_rsa.pub') }}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment