Ansible Push SSH Public key

Source: Internet
Author: User
Tags ansible playbook

Ansible Push SSH Public key

1 The management of the machine can be directly push the past

Using ssh-keygen-t RSA to generate a key pair,

!miyaoqq20141225124030.png!


Id_rsa the private key, which remains on the host, Id_rsa.pub is the public key that needs to be pushed to the management machine and renamed to the Authorized_keys file

Push to remote machine ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected][ip,hostname]


2 machine Many cases, the use of Ssh-copy-id method some time-consuming, using Ansible-playbook push Ymal, here used to Authoried_keys module, can refer to http://docs.ansible.com/ Authorized_key_module.html


At the same time hosts content

!neirongqq20141225125319.png!


<pre>

[Email protected] ~]# ansible-playbook/etc/ansible/rsync_key.ymal-f 10

</pre>

Appear

<pre>

Error:authorized_key is isn't a legal parameter at this level in an Ansible Playbook

</pre>


may be Ymal language format problem, or rsync_key.ymal problem, in error


Modify Rsync_key.ymal Content


1 # Using Alternate directory locations:

2-hosts:test89

3 User:root

4 tasks:

5-name:ssh-copy

6 Authorized_key:user=cuibo key= "{{lookup (' file ', '/root/.ssh/id_rsa.pub ')}}"

7 Tags:

8-sshkey


Finally, the SSH public key is pushed successfully.

Ansible Push SSH Public key

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.