Linux两台服务器之间复制文件及免密码登录的方法
1. 在服务器A生成密钥对
ssh-keygen # 输入后一直回车即可
2.将id_rsa.pub拷贝到服务器B的 ~/.ssh/目录下
3.将id_rsa.pub内容追加到authorized_keys中, 无则创建
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
4.在A服务器中校验是否成功
[root@izuf6hbxq1arw2zlnapn9sz .ssh]# ssh root@B服务器的ip
Last login: Thu Feb 10 14:08:35 2022 from x.x.x.x
Welcome to Alibaba Cloud Elastic Compute Service !
[root@iZuf69838n99jwr43ocfrsZ ~]#
5.使用场景
一般使用在自动化脚本或者自动化部署上面, 如: gitlab-ci