Skip to content

Commit 12338d3

Browse files
committed
Merge branch 'master' of git@github.com:help/help.github.com
2 parents a709406 + 5165e69 commit 12338d3

File tree

4 files changed

+77
-6
lines changed

4 files changed

+77
-6
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
22
layout: default
33
title: Generating SSH keys
4+
description: How to generate SSH keys and add them to GitHub
5+
categories: setup
46
---
57

68
Attempting to redirect to the guide for your OS. If the redirect fails, pick your OS:
79

8-
* "Mac":msysgit-key-setup
9-
* "Windows":mac-key-setup
10+
* "Windows":msysgit-key-setup
11+
* "Mac":mac-key-setup
12+
* "Linux":mac-key-setup
1013

1114
<script type="text/javascript">
1215
if (navigator.appVersion.indexOf("Win") != -1) {window.location = 'http://help.github.com/msysgit-key-setup/'}
1316
else if (navigator.appVersion.indexOf("Mac") != -1) {window.location = 'http://help.github.com/mac-key-setup/'}
17+
else if (navigator.appVersion.indexOf("X11") != -1 || navigator.appVersion.indexOf("Linux") != -1) {window.location = 'http://help.github.com/linux-key-setup/'}
1418
</script>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
layout: default
3+
title: Generating SSH keys (Linux)
4+
description: Setting up SSH keys on Linux
5+
categories: linux
6+
main_category: setup
7+
---
8+
9+
This guide will step you through the process of generating a keypair on linux and uploading it to GitHub. We use Ubuntu and bash in this guide, command may vary depending on your linux flavor and shell.
10+
11+
Generating an SSH key on linux is a fairly straightforward process. First and foremost, open up a "terminal":https://help.ubuntu.com/community/UsingTheTerminal.
12+
13+
h2. Backup and remove existing keys
14+
15+
Unless this is your first time setting up ssh or git on your computer, you should double check that keys do not already exist. If they do you can either use the existing key(s) or remove them. In either case, you should make a backup of the keys.
16+
17+
<pre class="terminal">$ cd ~/.ssh
18+
$ ls
19+
config id_dsa.pub
20+
id_dsa known_hosts
21+
$ cd ..
22+
$ mkdir ssh_key_backup
23+
$ cp .ssh/id_rsa* ssh_key_backup
24+
$ rm .ssh/id_rsa*</pre>
25+
26+
Here we have an existing keypair, @id_rsa@ and @id_rsa.pub@, which we've copied into @~/ssh_key_backup@ before removing. By default, ssh will use keys in @~/.ssh@ that are named @id_rsa@, @id_dsa@ or @identity@.
27+
28+
h2. Generating a key
29+
30+
p(. _If you have an existing keypair you wish to use, you can skip this step._
31+
32+
Now that we're certain ssh won't use an existing key, it's time to generate a new keypair. Lets make an RSA keypair:
33+
34+
<pre class="terminal">$ ssh-keygen -t rsa -c "tekkub@gmail.com"
35+
Generating public/private rsa key pair.
36+
Enter file in which to save the key (/Users/tekkub/.ssh/id_rsa):
37+
Enter passphrase (empty for no passphrase):
38+
Enter same passphrase again:
39+
Your identification has been saved in /Users/tekkub/.ssh/id_rsa.
40+
Your public key has been saved in /Users/tekkub/.ssh/id_rsa.pub.
41+
The key fingerprint is:
42+
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db tekkub@gmail.com</pre>
43+
44+
At the first prompt you can just hit enter to generate the key with the default name. *You should use a good passphrase with your key.* See "Working with SSH key passphrases":/working-with-key-passphrases for more details on why you should use a passphrase and how to avoid re-entering it every time you use your key.
45+
46+
p(. *Note:* If you don't use the default key names, or store your keys in a different path, you may need to run @ssh-add path/to/my_key@ so that ssh knows where to find your key.
47+
48+
h2. Adding the key to your GitHub account
49+
50+
Now launch your browser and open the "account page":https://github.com/account. In the "SSH Public Keys" section click "add another public key", then paste your public key into the "key" field. If you leave the title blank the key comment (your email) will be used for the title.
51+
52+
Make sure you use the public key (@id_rsa.pub@ in our example), and do not add any newlines or whitespace inside the key. To ensure you copy the key correctly, you can copy the key directly into the clipboard from the terminal using "xclip":http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/:
53+
54+
<pre class="terminal">$ sudo apt-get install xclip
55+
$ cat ~/id_rsa.pub | xclip</pre>
56+
57+
!/images/add_key.png!
58+
59+
h2. Testing things out
60+
61+
Testing if our new key works is simple:
62+
63+
<pre class="terminal">$ ssh git@github.com
64+
Hi tekkub! You've successfully authenticated, but GitHub does not provide shell access.
65+
Connection to github.com closed.</pre>
66+
67+
If you do not get the "successfully authenticated" message, check out the "troubleshooting guide":http://github.com/guides/addressing-authentication-problems-with-ssh.

‎_posts/2009-06-15-mac-key-setup.textile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: default
33
title: Generating SSH keys (OSX)
44
description: Setting up SSH keys on Mac OSX
5-
categories: mac setup
5+
categories: mac
66
main_category: setup
77
---
88

@@ -12,7 +12,7 @@ Generating an SSH key on OSX is a fairly straightforward process. First and for
1212

1313
h2. Backup and remove existing keys
1414

15-
Unless this is your first time setting up ssh or git on your computer, you should doublecheck that keys do not already exist. If they do you can either use the existing key(s) or remove them. In either case, you should make a backup of the keys.
15+
Unless this is your first time setting up ssh or git on your computer, you should double check that keys do not already exist. If they do you can either use the existing key(s) or remove them. In either case, you should make a backup of the keys.
1616

1717
<pre class="terminal">$ cd ~/.ssh
1818
$ ls

‎_posts/2009-06-15-msysgit-key-setup.textile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: default
33
title: Generating SSH keys (Win/msysgit)
44
description: Setting up SSH keys with msysgit on Windows
5-
categories: windows setup
5+
categories: windows
66
main_category: setup
77
---
88

@@ -12,7 +12,7 @@ Generating an SSH key with msysgit is a fairly straightforward process. First a
1212

1313
h2. Backup and remove existing keys
1414

15-
Unless this is your first time installing msys on your computer, you should doublecheck that keys do not already exist. If they do you can either use the existing key(s) or remove them. In either case, you should make a backup of the keys.
15+
Unless this is your first time installing msys on your computer, you should double check that keys do not already exist. If they do you can either use the existing key(s) or remove them. In either case, you should make a backup of the keys.
1616

1717
<pre class="terminal">$ cd ~/.ssh
1818
$ ls

0 commit comments

Comments
 (0)