openssh生成ed25519的密钥对并实现服务器间免密钥登录

打印 上一主题 下一主题

主题 1111|帖子 1111|积分 3333

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本文讲解如何用openssh生成ed25519的密钥对并实现服务器间免密钥登录。
   注意:全部操纵均在客户机侧
  一、生成 ED25519 密钥
用需要免密登录的用户(本例为username) 运行“ssh-keygen -t ed25519 -b 256”
  1. [username@localhost ~]$ ssh-keygen -t ed25519 -b 256
  2. Generating public/private ed25519 key pair.
  3. Enter file in which to save the key (/home/username/.ssh/id_ed25519):
  4. Enter passphrase (empty for no passphrase):
  5. Enter same passphrase again:
  6. Your identification has been saved in /home/username/.ssh/id_ed25519
  7. Your public key has been saved in /home/username/.ssh/id_ed25519.pub
  8. The key fingerprint is:
  9. SHA256:TxLFDN0ERV3qM7d0OfTXCylXHrXQilvZTymabIcYhTE username@localhost.localdomain
  10. The key's randomart image is:
  11. +--[ED25519 256]--+
  12. |        .E=*+o..o|
  13. |         o=.. ooo|
  14. |        . . . ==.|
  15. |         o . *=o*|
  16. |        S =.*+=*B|
  17. |         = Bo.o+B|
  18. |          o .  o |
  19. |                 |
  20. |                 |
  21. +----[SHA256]-----+
  22. [username@localhost ~]$
复制代码
一起回车,即可看到在当前用户家目录下生成了.ssh/id_ed25519的私钥和.ssh/id_ed25519.pub公钥文件
二、将公钥文件传给远端服务器对应帐号
使用 ssh-copy-id 下令来完成
  1. [username@localhost ~]$ ssh-copy-id -i ~/.ssh/id_ed25519 -p4422 username@192.168.1.76
  2. /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/username/.ssh/id_ed25519.pub"
  3. /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  4. /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
  5. (username@192.168.1.76) Password:
  6. Number of key(s) added: 1
  7. Now try logging into the machine, with:   "ssh -p 4422 'username@192.168.1.76'"
  8. and check to make sure that only the key(s) you wanted were added.
  9. [username@localhost ~]$
复制代码
三、测试验证
  1. [username@localhost ~]$ ssh -p4422 username@192.168.1.75
  2. Last login: Tue May 28 17:22:38 2024
  3. Authorized users only. All activities may be monitored and reported.
  4. [username@localhost ~]$
复制代码
可以看到,现在已经不需要密码即可以登录了。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

笑看天下无敌手

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表