步骤一: 生成本地密匙
如果本地没有密匙, 首先需要创建一个自己的密匙,使用ssh-keygen -t rsa
,一路点击回车键即可,密匙生成在用户的根目录下的 .ssh 文件夹,可以使用命令ls ~
查看是否有.ssh 文件夹。
步骤二:将密匙导入认证文件
执行命令 ssh-copy-id -i ~/.ssh/id_rsa.pub user@host_ip
,user
是linux主机登陆用户名,host_ip
是linux主机的ip地址。
执行成功返回一下消息代表已经成功了,试试看使用ssh user@host_ip是不是不需要输入密码啦
Now try logging into the machine, with: "ssh 'xxx@xx.xx.xxx.xxx'"
and check to make sure that only the key(s) you wanted were added
网友评论