Windows/Mac本地SSH密钥生成操作文档¶
1.1 适用系统¶
Windows 10/11(自带 OpenSSH)macOS(自带 OpenSSH)
1.2 生成密钥¶
打开终端¶
Windows请打开 PowerShell 或 CMD,Mac打开“终端” 输入以下命令:
ssh-keygen -t ed25519 -C "你的姓名拼音@组内邮箱或学号"
例如:
ssh-keygen -t ed25519 -C "zhangsan@example.com"
按回车后会出现如下提示:
Generating public/private ed25519 key pair.
Enter file in which to save the key (/c/Users/你的用户名/.ssh/id_ed25519):
直接按回车使用默认路径 接着提示:
Enter passphrase (empty for no passphrase):
1.3 查看并复制公钥¶
继续在终端输入:¶
Mac / Linux(终端):
cat ~/.ssh/id_ed25519.pub
Windows(PowerShell):
cat $HOME\.ssh\id_ed25519.pub
Windows(CMD):
type %USERPROFILE%\.ssh\id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... zhangsan@example.com
复制整行内容(以ssh-ed25519开头,到邮箱结尾),这就是你的公钥。
1.4 注意事项¶
私钥(id_ed25519)绝对不要发给任何人,不要上传到网络。 公钥(id_ed25519.pub)可以公开,用于服务器登记。
在OpenSSH7.0及以上版本中,Ed25519被默认支持并推荐。 生成密钥时使用-t ed25519即可: 如果你之前已经生成过 RSA 密钥(id_rsa.pub),也可以使用,但推荐使用 Ed25519。
本文阅读量 次本站总访问量 次
Authors: