Git, how to generate public key

2019-03-08 11:12发布

how to generate a public key(to be used in GitHub/GitLab) using command line [Git Bash].

The command below generates the error sh.exe": syntax error near unexpected token '('

I am using windows xp.

$ ssh-keygen -t rsa -C "xxxx@gmail.com"
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 xxxx@gmail.com

2条回答
混吃等死
2楼-- · 2019-03-08 12:14

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).

Steps how to do It

查看更多
Explosion°爆炸
3楼-- · 2019-03-08 12:15

The command to run is only

ssh-keygen -t rsa -C "you@example.com"

All the rest beginning with line 2 of your script is the output of ssh-keygen.

And replace you@example.com with your email address.

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.

查看更多
登录 后发表回答