码迷,mamicode.com
首页 > 其他好文 > 详细

Ansible ssh-key密钥认证配置

时间:2019-09-14 23:01:11      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:设置   ret   管理   ansible   密钥   情况   change   密码   class   

对于被管理服务器做免密码登录设置

1.在管理服务器生成ssh-key密钥

#ssh-keygen  //生成秘钥

root@hsz:/etc/ansible# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

c5:5a:29:c4:d6:8d:f7:2c:46:f8:a3:c1:d8:e9:5b:06 root@hsz

The key‘s randomart image is:

+--[ RSA 2048]----+

|       ... +     |

|       .o.+.+    |

|       ..+== o   |

|        .=E = o  |

|        S. = o   |

|          o o    |

|           +     |

|          .      |

|                 |

+-----------------+

 

#回车回车就行

 

2.将秘钥拷贝到被管理服务器上

#ssh-copy-id  -i ~/.ssh/id_rsa.pub -p 22 root@192.168.0.50

 技术图片

#一般这样的命令就行,即被管理服务器的ssh端口默认

#ssh-copy-id 192.168.0.50

# 那么接下来就可以进行远程操作了(将被管理服务器ip加到清单的情况下)

比如ping:

[root@hsz ~]# ansible 192.168.0.50 -m ping 
192.168.0.50 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
}, 
"changed": false, 
"ping": "pong"
}

Ansible ssh-key密钥认证配置

标签:设置   ret   管理   ansible   密钥   情况   change   密码   class   

原文地址:https://www.cnblogs.com/hszstudypy/p/11520275.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!