Ansible ssh-key密钥认证配置

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

# 在管理服务器生成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    |

|           +     |

|          .      |

|                 |

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

#回车回车就行

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

#ssh-copy-id  -i ~/.ssh/id_rsa.pub -p 22 [email protected]

 

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

#ssh-copy-id 192.168.0.50

 

 

 

你可能感兴趣的:(Ansible ssh-key密钥认证配置)