Last updated May 26, 2014.

This is a simple method to create, upload and verify an SSH Key with Drupal.org

Generate a key for the first time

Open the Git Bash window and change to the .ssh directory

cd ~/.ssh

If the .ssh directory does not exist, change to the user directory then create the .ssh directory and enter it.

cd ~
mkdir .ssh
cd .ssh

NOTE: Do not include any spaces in your keyname as it can cause problem when you upload your public key to some sites.
At the Git Bash prompt, enter:

ssh-keygen -t rsa (optional " -C keyname" where keyname is anything you want)

You should see:

Generating public/private rsa key pair.
Enter file in which to save the key (/u/.ssh/id_rsa):

Press 'Enter' here to accept the default

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Press enter to leave the passphrase empty.

Your identification has been saved in /u/.ssh/id_rsa.
Your public key has been saved in /u/.ssh/id_rsa.pub.
The key fingerprint is:
7e:f5:7e:51:ec:3d:2c:36:02:9d:5b:89:4a:3a:b7:b5 keyname

Copy your Key

At the Git Bash prompt, type:

cat .ssh/id_rsa.pub

You should see something like:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq/9IAUH
OBaagayPGPItqx8cuebGiCdR7an5o6XYefcWgeNxa8gYNjOUWs3TSw7if6o4GnG/4Jwk/f8abaG9BYv/OpLlpeV rgkKWhVL56yWgd8Pbry3y6yM/S3T3lfYYdfbzo8JecHFnFrhCdYXbftg2qcvfRq/iXaoHQlJzUkr5zpu1pyD7Pd M/1H6YlBlP18Ge+lAfgLZd9x8nxMNAq+0zrozitIRC/kR5LE7HbJWBrFhFZQqFpVSSXwIZDpou6Js7c5GP2S/0 O+z2FvrbjvP9g4/mrRv48a3R/0tc4U0GWlAFMp6W/CZjaYQe74/3Y2rGvYLyh762AqVagWOnnmw== keyname

Even though you can see it, right there, you can't copy and paste it unless you've changed some Windows system settings. Instead, open the id_rsa.pub file with a text editor like Notepad. It's located at /u/.ssh/ in our example. The path on your machine is visible in Git Bash after the "Enter file in which to save the key".

Put your key on Drupal.org

  1. Log in to Drupal.org.
  2. Click "Your Dashboard" » Profile » SSH Keys » Add a public key
  3. Paste your key into the text area. Anything after the == will become the title of your key, so if you've been following along, you can leave the title blank. It's purely for your convenience, so you can also name it anything you want, perhaps the name of the computer the key associates with (my laptop).

Test your key

To test your key, clone an actual project from Drupal.org. You can use the example below or locate the clone command for a project you actually need.

NOTE: The below code attempts to log you into git.drupal.org. However, you can not login until you have created your git username and agreed to the Drupal version control system rules. To do this, login into your account on drupal.org, select Your Dashboard tab, select the Profile tab, select Edit, select Git Access. On the Git Access page, you will need to agree to the Drupal version control rules and follow the rest of the instructions on this page. Once you have completed all of the drupal.org steps, you can proceed with the below code.

Also you will need to change the text "username" to the user name you created on the Drupal.org Git Access page.

git clone username@git.drupal.org:project/examples.git

You should see:

Initialized empty Git repository in /home/melissa/examples/.git/
The authenticity of host 'git.drupal.org (140.211.10.6)' can't be established.
RSA key fingerprint is 69:35:9f:1b:a8:26:ad:6d:cc:93:29:25:6e:d7:25:2b.
Are you sure you want to continue connecting (yes/no)?

Type 'yes' at the prompt and press 'Enter'.
Next you'll see something like:

Warning: Permanently added 'git.drupal.org,140.211.10.6' (RSA) to the list of known hosts.
remote: Counting objects: 1737, done.
remote: Compressing objects: 100% (619/619), done.
remote: Total 1737 (delta 1176), reused 1667 (delta 1106)
Receiving objects: 100% (1737/1737), 525.92 KiB | 846 KiB/s, done.
Resolving deltas: 100% (1176/1176), done.

If you are not asked for a password, you have successfully set up a new SSH key.
If you're just testing, then finish by removing the clone directory you just downloaded:

cd ~
rm -rf examples

That's it! You are done.

Comments

OddJob’s picture

You should not have spaces in the key name, while you can use any name, firstname@lastname is a good choice provided it has no spaces!! Use your firstname and lastname.

If you have spaces in your name it will cause you errors.

Also in order to test using your durapl.org name - you have to make sure you agree to the get access section of your drupal profile.

Or you can use "git@git.drupal.org". If you agree under your profile, then you can use your "username@git.drupal.org.

Here is a link to more on using "git@git.drupal.org" instead of "[git-user]@git.drupal.org": Git documentation remember git-user is referring to your user name!

On that page you will find this section: Why do I need a username if I'm using SSH keys?
You don't! You can use also use the familiar git@git.drupal.org:project/[projectname].git.

Note: the instructions should have been edited to reflect some of this commentary.

mavaddat’s picture

I was able to insert a key-name with spaces (like "FIRSTNAME LASTNAME@COMPUTER") and the connection, authentication, and example cloning worked fine for me.

kaizerking’s picture

when entered cat .ssh/id_rsa.pub it says "no such file or directory"(wind xp)

clivesj’s picture

In the example we are already in the directory .shh so we enter:
cat id_rsa.pub

rakesh.gectcr’s picture

Please check this,

https://help.github.com/articles/generating-ssh-keys

It may help you..

Rakesh James

myglobaldata_gil’s picture

A question to clarify the instruction for "Test your key." Several individuals tried using the line: username@git.drupal.org:project/examples.git
and in return, we were asked to enter our drupal password and the test did not run. However, when we used:
git@git.drupal.org
the Test ran successfully. Could it be that the "username" option is no longer valid and should be removed?

MyGlobalData_Gil