使用 ssh 公私钥对登陆服务器
1.查看本机是否已经生成过 SSh key
shell
ls -al ~/.ssh
2.使用命令生成
shell
ssh-keygen -t rsa -C "chenlj"
一路回车,即可生成公司要对
SSH 秘钥的两个文件: id_rsa —— SSH 秘钥的 私钥 (Private Key) id_rsa.pub —— SSH 秘钥的 公钥 (Public Key)
3.复制文件
1.将 id_rsa.pub 复制给 authorized_keys
shell
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
2.将 id_rsa 复制到需要的地方
即可使用该私钥进行登陆