Git,如何生成公钥
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3828823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git, how to generate public key
提问by Q_Mlilo
how to generate a public key(to be used in GitHub/GitLab) using command line [Git Bash].
如何使用命令行 [Git Bash] 生成公钥(在 GitHub/GitLab 中使用)。
The command below generates the error sh.exe": syntax error near unexpected token '('
下面的命令会产生错误 sh.exe": syntax error near unexpected token '('
I am using windows xp.
我正在使用 windows xp。
$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/xxxx/.ssh/id_rsa.
Your public key has been saved in /c/Users/xxxx/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
回答by Residuum
The command to run is only
要运行的命令只是
ssh-keygen -t rsa -C "[email protected]"
All the rest beginning with line 2 of your script is the output of ssh-keygen.
从脚本的第 2 行开始的所有其余部分都是 ssh-keygen 的输出。
And replace [email protected] with your email address.
并将 [email protected] 替换为您的电子邮件地址。
Have a look at the manual for ssh-keygen
to look for additional options. You should probably use a longer key by adding -b 4096
to the option list.
查看手册ssh-keygen
以查找其他选项。您可能应该通过添加-b 4096
到选项列表来使用更长的密钥。
回答by Hazarapet Tunanyan
Here is the command
这是命令
ssh-keygen -t rsa -b 4096 -C "[your github's email]"
# Creates a new ssh key
# Generating public/private rsa key pair.
This will generate a key for you.You have to copy that and insert into your Github's account (just one time).
这将为您生成一个密钥。您必须复制它并插入到您的 Github 帐户中(仅一次)。
回答by avivamg
Solution: ssh-keygen -t rsa
解决方案:ssh-keygen -t rsa
Explanation: ssh-keygen
is a tool for creating new authentication key pairs for SSH. Such key pairs are used for automating logins, single sign-on, and for authenticating hosts
说明:ssh-keygen
是为 SSH 创建新的认证密钥对的工具。此类密钥对用于自动登录、单点登录和验证主机
(for example cloning project from your private repo on Github straight to your aws machine).
(例如,将您在 Github 上的私人仓库中的项目直接克隆到您的 aws 机器上)。
Options: You can perform more complicated operations and using flags in order to generate a tailor-made key according to your use case, extended functionality are more powerful and secured. The basic flags are: bits
(Large integers making the the RSA key be less vulnerable and hard to crack), passphrase
(similar to password) , type
(dsa/ecdsa/ed25519/rsa) , comment
for the specific ssh token (email or user name) and output key
(default store on ~/.ssh/ path)
选项:您可以执行更复杂的操作并使用标志以根据您的用例生成量身定制的密钥,扩展功能更强大和安全。基本标志是:(bits
大整数使 RSA 密钥不易受到攻击且难以破解)、passphrase
(类似于密码)、type
(dsa/ecdsa/ed25519/rsa)、comment
用于特定的 ssh 令牌(电子邮件或用户名)和output key
(默认存储在 ~/.ssh/ 路径上)
Synopsis:ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa] [-N new_passphrase] [-C comment] [-f output_keyfile]
概要:ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa] [-N new_passphrase] [-C comment] [-f output_keyfile]
Example:
示例:
ssh-keygen -b 4096 -t rsa -n "tHiSiaPasSWoRd" -c "[email protected]" -f ~/.ssh/id_rsa