Tech, Gadgets, Photography, Social Media and Poor Spelling

Moving SSH keys for password-less SSH login.

I’ve been using SSH an awful lot this week in an effort to resolve some issues with overseas users specifically with ssh -X. This great tip however assists in passwordless SSH which is useful if you are running scripts between two known hosts. While the Mac is being used as the host the principle applies for Linux/BSD too..


For those that rely on passwordless logins via ssh, rather than generating a new SSH key for a new client machine, you can easily move SSH keys from one computer to another. This is a quick and easy solution for a temporary machine or username or for use on an auxiliary workstation. You could also use this to copy SSH keys between user accounts on the same machine.

Moving SSH Keys Between Computers

If you’re already connected to a networked Mac, using the Finder is an easy way to copy the SSH keys. First you’ll want to show hidden files in OS X either through defaults write or a tool likeDesktopUtility, then just open up the .ssh directory on both machines and do a drag and drop:

Migrate SSH Keys through Finder

On the other hand, if you’re already in Terminal to enable hidden files, you may as well just use the command line to move them over.

Copying SSH Keys from the Command Line
Using the terminal is faster for many of us, you’ll obviously have to be connected to the other computer through a network for this to work.

cp .ssh/id_rsa* /Network/path/to/username/.ssh/

Simple enough, and will work for any version of OS X and most variations of unix or linux.

If you wanted to, you could also zip the key files and then transfer them through AirDrop, but that’s probably more work than necessary.

Because SSH keys allow for passwordless logins, you’ll want to securely delete or better yetsecurely format the hard drive before it goes to a new owner. This is especially true with temporary computers or loaner machines.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


This entry was posted on July 14, 2012 by in Apple, BSD, howto, Linux, osxdaily, tip and tagged , , , , , , , .
%d bloggers like this: