Linux配置免密
1、进入ssh目录
cd ~/.ssh
2、若不存在则创建该目录
mkdir -p ~/.ssh
3、查看是否有公钥
cd ~/.ssh
ll | grep id_rsa.pub
4、若没有,则公钥和私钥(然后敲(三个回车),就会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥))
ssh-keygen -t rsa
5、查看公钥
cat ~/.ssh/id_rsa.pub
6、复制公钥内容到authorized_keys文件中,若authorized_keys文件不存在则创建(例如下,依次配置即可)
touch ~/.ssh/authorized_keys
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHamw4t73QLVaq3shYxNq2mqRYf5XvUgexh26BUIon8gKcOpeGifB7E3nW0Kb1LJ/eG8xfoiHYKYs4OWNWQ4po24884Yo+mi2+cr5CIkk0rOvuYikHt70OeKV+Wp6FLVVK6kTXWZ6sWjGE9b2h/EawQvJy7j3lnNTFic6YuP0WNNSo7XplAxak4IZi+Vt5UYqVBj35oQM7OXjWrrv3IlmGIJCEnOdjTXOucNMSXS7iUIAYWFhz5YtnSQJKHt/9/4/ECthQBZU0gTCdK62US6Jj8r3igzTqB2gOLy20Jj7xVKGeDmAHXc27AVtdd1dTBW8GnUgJmBL6BZzOdCfIHI01 root@192.168.67.1" >> ~/.ssh/authorized_keys
cat ~/.ssh/authorized_keys
7、配置/etc/hosts文件
echo "192.168.67.1 master01" >> /etc/hosts
8、完成之后测试,第一次配置需要输入yes进行确认
ssh master01