与多个SSH密钥对配对 [英] Ansible with multiple SSH key pair
问题描述
我是Ansible的新手.我可以根据我的测试要求对其进行测试,并且可以正常工作.为了在管理节点和客户端节点之间建立连接,我使用的是已经创建的ssh密钥对.如何使用具有不同SSH密钥对的另一个节点?供参考,我正在考虑使用具有不同密钥对的3 ec2-instance.
I am new to Ansible. I am able to test it and its working fine with my test requirment. For making connection between management node and the client node I am using already created ssh key pair. How can I use another node with different SSH key pair? For reference I am considering 3 ec2-instance with different key pairs.
推荐答案
好消息-在基本的用例中,这相当容易.只需在可用库存中使用ansible_ssh_private_key_file
参数.
Good news- in a basic use case, this is fairly easy. Simply use the ansible_ssh_private_key_file
parameter in your Ansible inventory.
以下是一些从我的个人档案中窃取的示例:
Here are some examples purloined from my personal file:
$ cat hosts.ini
[server1]
54.1.2.3 ansible_ssh_private_key_file=~/.ssh/server1.pem
[testservers]
ec2-54-2-3-4.compute-1.amazonaws.com ansible_ssh_private_key_file=~/.ssh/aws-testserver.pem ansible_ssh_user=ubuntu
ec2-54-2-3-5.compute-1.amazonaws.com ansible_ssh_private_key_file=~/.ssh/aws-testserver.pem ansible_ssh_user=ubuntu
[piwall]
10.0.0.88 ansible_ssh_private_key_file=~/.ssh/raspberrypi.pem ansible_ssh_user=pi
这篇关于与多个SSH密钥对配对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!