Posted 01.03.2013

Setting Up a Site with SSH

Recently, I was trying to set up a project for a client using SpringLoops. I had worked with git before through gitHub, but never SpringLoops and never with SSH.

Several hours later, I got everything up and running. So, in an effort to save you from the same heartache, I’d thought I’d share.

Login to your SpringLoops account.

Spring Loops Account Page
Click on your project folder

Spring Loops - Source and Deploy Tab
Click on the Source and Deploy tab

Spring Loops - My Repository Access
Click on the My Repository Access Details button

If a repository has already been set up for a particular project, you can click on the Source and Deploy tab and look for the green Access Details button
Spring Loops - Repository Access
A modal window will appear displaying your repository access details. Click on the Manage link under SSH keys.

Add an SSH Key
Then, click on the Add a new SSH key tab.

Now, switch over to the Terminal.

First, you’ll need to check for existing SSH keys.

In Terminal run:

cd ~/.ssh

This checks to see if there is an existing directory named .ssh in your user directory.

If there is, you’ll want to backup your existing keys.

ls

This lists all the subdirectories in the current directory. You should see something similar to the following:

config id_rsa id_rsa.pub known_hosts

Let’s create a folder to hold our backups

mkdir key_backup

Then, we want to copy all our existing keys into this folder

cp id_rsa* key_backup

Then, get rid of the duplicate files.

rm id_rsa*

Now, we need to generate a new SSH key. If you’re on a Mac, this is already built in (I think). At least, I didn’t have to do anything special.

ssh-keygen -t rsa -C “your_email@youremail.com

This generates a new SSH key using the email address you provide.

The prompt should then say something like:

Enter file in which to save the key (/Users/you/.ssh/id_rsa):

Simply, press enter.

Now, you’ll want to enter a passphrase. On Mac OSX Leopard and later, there’s an ssh-agent built in so your keys can be saved in the system’s keychain to make life (a little) easier.

Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Then, you should see something similar to the following:

Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db
your_email@youremail.com

Excellent! Now, you just need to add the key to SpringLoops. Unfortunately, it isn’t as easy as copy and paste…well, kind of. You have to make sure you copy the code exactly. No extra whitespace.

In terminal, type

pbcopy < ~/.ssh/id_rsa.pub

This copies everything you need to your clipboard. Now, go back to your SpringLoops window. You should still have the Add a new SSH key window open.
Add an SSH Key
Paste your key into the textarea. Then, click on the blue button, Create this New Key. You’ll now see your key listed under the Manage your SSH keys tab.

Whew. We’re almost done.

I know just enough about git to be dangerous. Half the time I use the Terminal, the other half of the time, I use a GUI. I’m always afraid I’ll be one character off and do something permanently damaging in the Terminal. Besides, as a designer, a user interface is always better (well, as long as it’s well designed). In this particular instance, I’ll be using Tower.

I came across Tower, because it was Chris Coyier’s weapon of choice in his Getting off FTP and onto Git Deployment with Beanstalk screencast. He also has another screencast, Let’s Suck at GitHub Together that’s on my list of things to watch.

Tower - Repositories
Click on the Repositories button in the top left.

Tower - Manage Repositories

Click on the Manage Repositories button.
Tower - Clone Remote Repositories
Click on the Clone Remote Repository button.
SpringLoops - Repository Access Details
Now, go back to SpringLoops and get your SSH address.

Tower - Clone Remote Details
Paste it in the Repository URL in Tower.

Tower - Clone Remote Details
Change Authentication to Private Key.

Under Key Password enter your passphrase that you used when creating your SSH Key.

Under, Clone To: find the directory you want to save your repository in.

Click on the Clone button.

Magic.

See?! That wasn’t that hard…if you know what you’re doing. gitHub has some excellent resources and documentation on their site. — and if you’re using gitHub instead of SpringLoops, the steps are pretty similar. Feel free to check out gitHub’s SSH guide.