Back to home

配置部署ansible

安装:

apt-get install ansible

生成密钥对:

密码:免密登陆时,中间直接回车
root@65dc01ff4796:/var/jenkins_home/tools/ansible# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa_ansible
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa_ansible.
Your public key has been saved in /root/.ssh/id_rsa_ansible.pub.
The key fingerprint is:
SHA256:MaCnTa1gdU1X06Rd/QJdUcxP6ti3lppEjJFpr3oboyU root@65dc01ff4796
The key's randomart image is:
+---[RSA 2048]----+
| o .o. .ooBO|
| o + ..+ .+B|
| + o + = ..o+|
| . * . o. = o o|
| . o S . B . |
| + o .|
| E = . .o|
| =.+ .+ |
| o...oo |
+----[SHA256]-----+

同步公钥文件:

# ssh-copy-id -i /root/.ssh/id_rsa_ansible.pub root@client01.example.com
# vi /etc/ssh/ssh_config
IdentityFile ~/.ssh/id_rsa_ansible