# SSH免密配置
## 1,生成ssh密鑰
``` shell
ssh-keygen -t dsa
```
## 2,把公鑰(鎖)發送到被管理主機上
``` shell
ssh-copy-id -i /root/.ssh/id_dsa.pub root@172.16.1.41
```
## 3,把公鑰(鎖)免密碼發送到被管理主機上
```
#非交互式 分發公鑰
yum install sshpass -y
#sshpass -p123456 ssh-copy-id -i /root/.ssh/id_dsa.pub -o StrictHostKeyChecking=no root@172.16.1.31
sshpass -p123456 ssh-copy-id -i /root/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no root@172.16.1.31"
```
```shell
#非交互式創建 鑰匙鎖頭
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
```