« Filesystem Sharing Between OSX and Ubuntu | Main | Look Out, Boyd Tinsley »

ssh/scp Login Without Password

I'd been wanting to figure this out for awhile, and yesterday finally took a few minutes to dig up the answer, which I found most clearly stated here by Mathias Kettner.

If you want to be able to login to multiple machines, you still only have to do the first step once. After you've created the public and private key files once, you can copy the same public key to each server using the steps that follow.

NOTE: I've slightly modified these directions from Mathias' copy to be more pertinent to the specific case of a local copy of Mac OSX connecting to remote servers, but the resulting commands are identical.

First open a terminal session on your Mac and generate a pair of authentication keys. Do not enter a passphrase:

your-computer:~> ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Now use ssh to create a directory ~/.ssh as user myusername on myserver.com. (The directory may already exist, which is fine):

your-computer:~> ssh myusername@myserver.com mkdir -p .ssh

myusername@myserver.com's password:

Finally append your new public key to myusername@myserver.com:.ssh/authorized_keys and enter myusername's password one last time:

your-computer:~> cat .ssh/id_rsa.pub | ssh myusername@myservername.com 'cat >> .ssh/authorized_keys'

myusername@myservername.com's password:

From now on you can log into myservername.com as myusername from your terminal without a password:

your-computer:~> ssh myusername@myservername.com



Where am I?

Recent Photos

Powered by
Movable Type 3.35