失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 本地mac配置ssh免密登录远程linux服务器

本地mac配置ssh免密登录远程linux服务器

时间:2020-10-30 11:48:30

相关推荐

本地mac配置ssh免密登录远程linux服务器

本地mac配置ssh免密登录远程linux服务器

每次输入密码登录服务器也就罢了,结果scp时每次都要输入密码,分分秒秒阿西吧。哈哈哈,回归正题,配置免密登录后,畅通无阻啊,哈哈哈

检查自己~/.ssh目录下查看所有公私钥文件,拥有.pub结尾的文件是公钥文件,无.pub的是私钥文件。

cd ~/.sshls

只出现如下文件夹known_hosts

生成公私钥对,一路回车

ssh-keygen

ls查看文件:当前目录下会多了一对公私钥对id_rsa、id_rsa.pub

3. 上传公钥到服务器,这一步从本地将公钥文件上传到服务器指定目录。

ssh-copy-id -i id_rsa.pub root@111.111.111.111

出现以下内容

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.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[这里键入密码]Now try logging into the machine, with: "ssh 'root@111.111.111.111'"and check to make sure that only the key(s) you wanted were added.

ssh-add

ssh-add -K id_rsa

到此为止就完成了,十分便捷@_@

如果觉得《本地mac配置ssh免密登录远程linux服务器》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。