linux免密码登陆

  1. 生成密钥
 ➜  .ssh ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ExgdQNetjvhIt7B9BXQ3tCOTSpq5HP+s3UZlQS42bKg xxxx@xxxdeMacBook-Pro.local
The key's randomart image is:
+---[RSA 2048]----+
|     .+ooo . .o. |
|       +. o =.+o |
|      . ...++Boo.|
|         *+.ooo.o|
|       .SE..   o |
|      +.o=. . .  |
|     . Bo... .   |
|      o + .+ ..  |
|         ...+..  |
+----[SHA256]-----+
  1. 公钥上传到服务器
scp -P 22000 ~/.ssh/id_rsa.pub username@192.168.0.141:~/.ssh/temp001

登录服务器,公钥保存为authorized_keys

cat ~/.ssh/temp001 >> ~/.ssh/authorized_keys
rm ~/.ssh/temp001
  1. 配置本地ssh config文件
➜  .ssh touch config

config文件内容如下

Host hdhost
  HostName 192.168.0.141
  Port 22000
  User root
  IdentityFile ~/.ssh/id_rsa
  1. 免密码登录
➜  .ssh ssh hdhost
Last login: Sun Jun  3 22:34:40 2018 from 192.168.0.141
Welcome to Alibaba Cloud Elastic Compute Service !
[root@izuf61kij6ti02tzbzl3pqz ~]#
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,982评论 19 139
  • [配置Linux 免密码登陆](#配置Linux 免密码登陆)[1 生成秘钥对,一路回车就好](# 1 生成秘钥对...
    不会写诗的王维阅读 685评论 0 0
  • SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group...
    shuff1e阅读 1,805评论 1 11
  • 一、单向无密码访问 单向无密码访问远程服务器操作比较简单,比如服务器A需要无密码访问服务器B(A–>B),那么只需...
    夏大王2019阅读 386评论 0 0
  • [玫瑰]20170723徐海波读《不输在家庭教育上》分享(上海,第346天) 《林文采谈教育:好家长应该做什么》摘...
    觉之灯阅读 107评论 0 0