Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 보안양파
- macos
- PlayBook
- XCP-ng
- x-pack
- Kibana server is not ready yet
- G-suite
- Proxy
- 로그인불가
- pfsense
- endpoint security
- Elasticsearch
- Windows
- ssh key 배포
- docker
- ansible
- centos 8
- xe guest utilities
- GitLab
- bash
- freebsd
- ELASTIC
- Kibana
- 한글가이드
- proxycfg
- elastic stack
- hardening
- application security
- miniconda
Archives
- Today
- Total
선 밖에 선 자유인
Ansible ssh key 배포 playbook 본문
ssh-key-deploy.yml
---
- hosts: all
gather_facts: no
user: vagrant
tasks:
- name: ssh-key delete
connection: local
shell: rm -f /home/vagrant/.ssh/id_rsa*
- name: ssh-key making
connection: local
command: "ssh-keygen -b 2048 -t rsa -f /home/vagrant/.ssh/id_rsa -q -N ''"
ignore_errors: yes
run_once: true
- name: import id_rsa.pub
connection: local
command: "cat /home/vagrant/.ssh/id_rsa.pub"
register: id_pub
run_once: true
- name: host key to known hosts
connection: local
shell: "ssh-keyscan -H {{ inventory_hostname }} >> ~/.ssh/known_hosts"
- name: .ssh dir
file:
path: /home/vagrant/.ssh
state: directory
mode: '0700'
- name: auth file making
file:
path: /home/vagrant/.ssh/authorized_keys
state: touch
mode: '0600'
- name: ssh key deploy
lineinfile:
dest: /home/vagrant/.ssh/authorized_keys
line: "{{ id_pub.stdout }}"
- name: ssh key deploy
lineinfile:
dest: /home/vagrant/.ssh/authorized_keys
line: "{{ id_pub.stdout }}"
** Ubuntu 18.04 의 경우 대상 시스템에 python 이 /usr/bin/python 에 없으면 에러가 발생하기도 함
간단히 아래와 같은 plyabook으로 링크를 생성해 주고 실행하면 됨
- name: python link
shell: ln -s /usr/bin/python3.6 /usr/bin/python
Comments