Mac OS X: How To Generate SSH Keys

If you use the Terminal for any amount of work, sooner or later you will probably come across the need to use SSH. SSH is a transfer protocol used to send data securely over the internet. It stands for Secure Shell. SSH has the ability to use keys, which will allow one computer to access another computer using really long encrypted password. Keys are considered more secure than passwords because they are much longer in length and can not be easily broken via brute force methods, like most passwords can.

Mac OS X is built on UNIX, and has SSH installed on all versions of Mac OS X by default. No extra software is necessary to use SSH on Mac OS X. But to generate an SSH key on Mac OS X takes a few steps.

Step 1: Open Terminal

First, open the Terminal app on your computer. The Terminal app resides in /Applications/Utilities. The easiest way to launch it is to open Spotlight with Command-Spacebar, and then start typing Terminal. You should see the app as the top selection. Click enter to launch it.

Mac OS X Terminal Application

The Terminal should open using your home directory as the default directory, but in case it doesn’t, do this:

cd ~/

Step 2: Check for existing keys

Now, inside your home directory, let’s see if you have any SSH keys already created:

ls -al ~/.ssh

If this is a brand new installation of Mac OS X, the .ssh directory might not even exist. (Pro Tip: Directories that have a period in front of them are hidden by default, meaning, you won’t see them listed in the Finder.)

If you have any keys already created, most likely they would be files listed with a “.pub” extension. Some default key file names are:


If you don’t have any keys already created, go to the next step to create one.

Step 3: Generate a new SSH key

In the terminal, enter this command:

ssh-keygen -t rsa -C ""

Substitute your email address for the one listed above.

Hit enter, and you should see the following message returned:

# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

Press enter to create a key using the default settings.

Next, you will be asked to enter a passphrase. A passphrase is essentially a password that will be used every time the key itself is used. It’s another layer of security. You can hit enter and bypass using a passphrase, but you are effectively limiting how secure your connection will be. Keys can be stolen, and without a passphrase, someone could use your keys without any consequence. If you forgo using the passphrase, be warned.

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

Once you enter your passphrase (or click enter to bypass entering a passphrase) you should see a confirmation that your key has been created, which will look something like this:

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

Step 4: Move key to remote server

Now that you have created a key, let’s move it to a remote server so we can connect to it.

First you will need to know the username of the account on the remote machine you will be connecting to, and you will need to know the remote machines address (either a fully qualified domain name, or an IP address).

Now, in the terminal, you will issue this command:

cat ~/.ssh/ | ssh user@ "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

If you are on a Linux system, you can try the following shortened command that does the same thing.

ssh-copy-id user@

To test that everything worked correctly, try to initiate an SSH session from your machine to the remote machine via the terminal. If it works, you should be prompted for your passphrase (unless you opted not to enter one) and once entered correctly, be looking at the prompt for a shell on the remote machine.

Category: OS X,Tutorial,UNIX,Web Development

Adobe Creative Cloud thoughts, one year in…

Adobe Creative CloudWhen Adobe announced their move from packaged releases to a pure subscription model last year, I wasn’t a fan. I’ve been an Adobe customer for nearly 20 years, and this move didn’t look like a good deal for anyone who wasn’t an Adobe employee or stockholder. But, at $29.99/month for the first year, I figured I’d give it a shot and re-evaluate after 12 months. Well, my 12 months are just about up, and here’s where I’m at. (more…)

Category: Opinion,Reviews,Web Development

Web Development on the Mac: Part 2 – MySQL

Installing MySQL on OS X can be as easy or as complex as you want it to be. On the complex side, since OS X is UNIX, you could install from source and build your own package. Or your could use the Homebrew package manager to install completely from the command line.

The easiest way to get MySQL installed on OS X is to use the packages built by MySQL. The packages are offered up in tarball or in DMG. Getting the DMG is going to give you the most ‘Mac’ like install. For the purpose of simplicity, this is the method we will use in this example. (more…)

Category: PHP,Tutorial,UNIX,Web Development

Web Development on the Mac: Part 1

Mac OS X has been my platform of choice for web developmet since the release of OS X 10.2. The UNIX underpinnings of the OS and the inclusion of Apache, PHP and other web technologies, coupled with other tools like Photoshop and an wide array of high quality text editors and IDEs make OS X a stellar platform for building websites and web applications.

This article will guide you through the many options you have in setting up a killer, comprehensive platform for building web apps. (more…)

Category: PHP,UNIX,Web Development

Camino reaches 2.0

The Camino browser team has released version 2.0 of the Gecko powered web browser. Version 2.0 brings a number of new features to the table for the browser, including…

  • Tab Overview: Think of it as Exposé for your open tabs.
  • Tabbed browsing improvements: You can (finally) reorder tabs, and when the number of tabs exceeds the window width, view open tabs in a drop down menu. Additionally, left and right scrollbars appear to allow you to scroll through the tabs.
  • Download notifications through Growl (if it is installed).

There are a number of other smaller improvements and bug fixes to the browser as well.

I have a soft spot for Camino. Back in the early days of OS X, Camino (then called Chimera), was the best browser, hands down available for the platform. As a web developer, using Mac OS X in those days was a difficult task. The included web browser, Internet Explorer 5, was a big steaming pile of shit. It was slow, buggy, and its rendering engine was nowhere near as robust as the Gecko rendering engine. When the first builds of Chimera appeared, it was like seeing the Marines appear on the beach with reinforcements. By the time Chimera 0.2 was released, it was my default browser. I stuck with Chimera/Camino until Safari hit the scene in 2003.

But I’ve always appreciated what Camino offers Mac OS X users – a small, fast, lightweight browser built on top of a rock solid rendering engine.

Congrats to the Camino team for shipping version 2.0!

Category: Software,Web Development

Safari 4.04 available

Safari 4.04 is available via software update. No word yet on whether the recent improvements to the webkit inspector landed in this update.

From the release notes:

This update is recommended for all Safari users and includes improvements to performance, stability, and security including:

Improved JavaScript performance
Improved Full History Search performance for users with a large number of history items
Stability improvements for 3rd-party plug-ins, the search field and Yahoo! Mail
For detailed information on the security content of this update, please visit this site:

Update: The Webkit Inspector improvements noted above are not included in Safari 4.04.

Update: It appears the keyboard shortcut for Top Sites, Command-Shift-1 has been removed from Safari 4.04. If you use this keyboard shortcut, you may want to hold off on upgrading.

Update: Looks like the shortcut has been changed to Alt-Command-1. That’s the sort of change you would expect to be detailed in the release notes, if your release notes had any meaningful, detailed descriptions.

Category: Software,Web Development

How To Enable PHP & MySQL in Snow Leopard

In previous versions of Mac OS X, Apple included PHP, but usually an older version that what was available at the time of the operating systems release. In Snow Leopard, Apple has included the just released PHP 5.3. Compared with other Mac OS X releases, Apple has made getting PHP and MySQL up and running much easier than before. (more…)

Category: Tutorial,Web Development

How to delete .pureftpd-upload files

One of the issues I routinely encounter when updating many of my WordPress site’s is Transmit’s failure to delete .pureftpd-upload files. These are zero byte, hidden files with permissions that prevent you from deleting them via your FTP client. The consensus seems to be that these files are left when an FTP client gets interrupted during upload. Since I use Transmit exclusively, my first assumption was these files were Transmit specific. Upon further investigation, it appears many other FTP clients suffer from creating these little monsters as well.

The only solution I have found to remove them is to use CPanel’s File Manager to navigate to where these files reside, and delete them. This can become quite the pain in the ass if you have several of these buggers floating about in your site.

Category: Web Development

Safari 3.1 released for Mac & Windows

Apple has released Safari 3.1 for Mac & Windows. New to Safari 3.1 are additions from the HTML5 spec, including new audio & video tags and a storage (database) API, along with significant Javascript optimizations, and new CSS tag support.

Safari 3.1 is a free download for Mac & Windows.

Category: Software,Web Development

Coda theme for TextMate

Love Coda? Love TextMate? Wish that you could get Coda’s syntax coloring for HTML in TextMate? Well, here’s my first quick stab at replicating Coda’s syntax coloring in TextMate. Download the CodaHTML.tmTheme file, unzip, double click, and enjoy.

Category: Software,Web Development

About the author

A user of Macs since they had silly names like Performa and Centris, Theodore Lee is a techie who prides himself on his vast knowledge of all things Apple. OS X Factor was started in 2001 (originally as macosxcentric), and continues to churn out tips, tutorials, reviews and commentary on the tech sector.