How to generate ssh keys (for github)

Q_Mlilo picture Q_Mlilo · Sep 30, 2010 · Viewed 45.7k times · Source

Question: How do I generate ssh private and public keys (to be used in GitHub/GitLab) using command line.

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

I am using 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]

Answer

Residuum picture Residuum · Sep 30, 2010

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.

And replace [email protected] 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.