# 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
```