1. 生成rsa密钥
参考“git多密钥”
2. 将公钥添加到远程服务器
法一:ssh-copy-id
root@adam-Latitude-3480:~/.ssh# ssh-copy-id -i id_rsa_penrose-testserver_Spark7_adam.qiang_ubuntu.pub root@192.168.1.221
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa_penrose-testserver_Spark7_adam.qiang_ubuntu.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
# 这里输入服务器的密码
root@192.168.1.221's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.1.221'"
and check to make sure that only the key(s) you wanted were added.
法二:手动拷贝
将公钥 id_rsa_xxx.pub 拷贝到服务器,然后添加到 authorized_keys
cat id_rsa_xxx.pub >> ~/.ssh/authorized_keys
❤
码字不易
,整理费时
;
copy之前
,请双手合十
。