Question

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
Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top