Category Archives: OS X

Passwordless SSH Login between OS X and Remote Server

terminal-iconIf you commonly ssh from your OS X computer to a remote server such as a web server it makes sense to set up passwordless ssh login so you can have a secure connection without having to always enter your password. Setting up passwordless login also allows you to run automated scripts to help with managing things like offsite backups. Scripts can’t be automated if they require someone to be present at your machine typing in passwords every time they run.

It’s worth noting that you may first want to check if you already have¬†existing ssh keys on your computer. This can be done by entering¬†cd ~/.ssh [enter] at your terminal. If you get a response back stating “No such file or directory” then you need to proceed with the following steps.

To set up passwordless login between a remote unix/linux server and your OS X machine fire up terminal and…

1. generate an RSA private key

ssh-keygen -t rsa -C “your_email@example.com”

2. copy the key to your clipboard

pbcopy < ~/.ssh/id_rsa.pub

3. ssh into the webserver

ssh username@yoursite.com (login with your password for the last time)

4. make a .ssh directory, if it doesn’t already exist

mkdir .ssh

5. create an authorized_keys file and paste in the key from mac that you just copied to your clipboard

vi .ssh/authorized_keys (paste in key from clipboard, save)

6. set permissions for necessary files and directories on webserver

chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

That’s all there is to it. These steps could all be combined into a single line but the above is much easier to follow.