• Home
  • About
  • Archives
  • Books
  • Colophon
  • Policies
  • Resume
  • Tumblr

zanshin.net

because not enough websites start with the letter “Z”

Feed on
Posts
Comments
Tumblr
« As Good As We Can Be
Synchronize Apple AddressBook Using Dropbox »

Managing ssh keys

Oct 9th, 2009 by mark

Earlier this evening, while not paying close enough attention to what I was doing, I managed to delete some semi-important files on my desktop at work. The error happened because I was remotely logged in via the command line and wasn’t paying attention to which machine I was actually working against. My error is recoverable but it gives me new respect for the working environment system administrators live in day in and day out.

The files I deleted where the public and private key pair that uniquely identify my work desktop, and the list of public keys my work desktop has added to its authorized keys list. No real harm done except that now when I try to remotely login to that computer I have to enter the password. I decided to start over and document the process so I can perform it again in the future, if need be.

Step One

Generate a key pair on each machine you regularly use. In my case I have two work computers, a desktop called Palantir and a laptop called Orthanc, and two personal computers, both laptops, called Eeyore and Tigger. On Unix based systems run the ssh-keygen command to create a new public and private key pair. Like this:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/mhn/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/mhn/.ssh/id_rsa.
Your public key has been saved in /Users/mhn/.ssh/id_rsa.pub.

The id_rsa file is my identification and private key. The id_rsa.pub file is my public key. In order to make copying the public key to other machines easier I made a copy of the id_rsa.pub file on each machine, using the machine’s name as a unique identifier.

$ cp id_rsa.pub machineName.pub

Step Two

Next I copied the public keys from each machine into a folder in my Dropbox:

$ cp .pub ~/Dropbox/public_keys/

Since I can access my Dropbox from all of my machines, and since the key files are named for the machine they represent, this is a elegant way to house them centrally. You could also use scp (secure copy) to accomplish the same thing:

$ scp machineName.pub you@othermahince.com:~/.ssh

Step Three

Once you have the key files on the remote machine or in  your Dropbox, ssh (secure shell) into that machine and change to the .ssh directory.

$ ssh you@remoteMachine.com
Password:
$ cd .ssh

Make sure the authorized_keys file exists in the .ssh directory using the touch command.

$ touch authorized_keys

Concatenate the public key from the other machine to the authorized_keys file,

$ cat machineName.pub >> authorized_keys

Repeat the concatenation for each machine you want access this computer from remotely.

Step Four

There is no step four. You’re done.

Step Five

I also used the named public key files to allow password-less access to my bitbucket account.

NB: These steps worked for me. You should probably read more about ssh keys, scp, and ssh before attempting to follow them. Especially if you’ve never done this before.

Tags: public key, scp, ssh

Posted in nerdliness

Comments are closed.

  • Welcome!

    Mark H. Nichols is a software architect, martial artist, nerd, cellist, and all around good guy. He works at Kansas State University in Manhattan Kansas, and lives with his wife, two cats, a pair of 7-foot Kawai concert grand pianos, a violoncello, nearly a dozen computers, and a 2010 Honda Insight EX. You can read more about Mark, and this site, or explore the archives.
  • last 3 tweets

    • Previous RT originally by @AaronBillard: 06:22:41 PM September 08, 2010 from Tweetie for Mac
    • RT I love how the earth has stopped spinning long enough for the major religions of the world to hold hands and say Terry Jones is an arse. 06:22:22 PM September 08, 2010 from Tweetie for Mac
    • There should be a proficiency exam before one is allowed to use the self check out lane. #walmart 12:22:26 AM September 08, 2010 from Twitter for Android
    • I just earned the Ranger Pin on @gowalla! http://gowal.la/r/25VbN 04:25:01 PM September 06, 2010 from Gowalla
    • The annual cricket invasion has begun. *crickets* 12:28:08 PM September 06, 2010 from Tweetie for Mac
    • No matter how much it changes, it's still your home town. 10:41:49 PM September 04, 2010 from Twitter for Android
    • Absolutely despise florescent lights. Especially early in the morning. Or afternoon. Evenings. Nighttime. Pretty much all the time. #gah 12:55:54 PM September 02, 2010 from Tweetie for Mac
    • @timbray We've used a Tchibo USB Internet Stick with prepaid data with some success in Stuttgart. Customer Service is nonexistent however. 01:34:03 PM September 01, 2010 from Tweetie for Macin reply to timbray
    • RT @timbray: A story of O: http://www.tbray.org/ongoing/When/201x/2010/08/31/A-Story-of-O 02:37:53 AM September 01, 2010 from Tweetie for Mac
    • Manual Froyo update went smoothly. First boot takes a *very* long time with several lengthy pauses. Patience pays off. http://bit.ly/9VyNdR 02:16:01 PM August 31, 2010 from Tweetie for Mac
  • Most Popluar

    • Installing PostgreSQL on Mac 10.6 (Snow Leopard)
    • Using jQuery to Create iGoogle Style Drag-and-Drop
    • geek. : nerdliness is next to godliness
    • Using SSHFS, MacFUSE, and Macfusion to Access Remote Filesystems
    • Solfège
    • Installing Tchibo Internet Stick on Mac OS X
    • Using CRON to Control TimeMachine Backups
    • Mac OS X 10.6.4 Update Fails
    • Flickr Upload Via Command Line
  • Categories

    • diversions
    • elsewhere
    • family
    • health
    • life
    • links
    • meme
    • nerdliness
    • photography
    • random
    • relationships
    • social issues
  • Archives

    • Blogroll

      • Change.gov
      • Elfenbein Klaviermusik Notes
      • Shawn Blanc
      • Sibylle Kuder

zanshin.net © 1996 - 2010 All Rights Reserved.

Policies | Web Hosting: Blue Host