Installing ssh-copy-id on MAC and connect through SSH without password

Update September, 1st 2014

The newer versions of port does not include the ssh-copy-id package anymore, but you can still use it cloning this repo from Github:

Hello everybody! I have some servers and always I have to login using SSH, but some passwords is very complex. So, you must copy your public key to the desired server and be happy.

Installing the command ssh-copy-id

I used to use mac ports to install packages on my Mac, so: sudo port install ssh-copy-id Now you have the command installed on /opt/local/bin/ssh-copy-id. Just create a symbolic link to that: sudo ln -s /opt/local/bin/ssh-copy-id /usr/bin/ssh-copy-id

Copying your public key to server

Now you only have to run the command and be happy! The server will ask for password, and this will be the last time you type the code!

ssh-copy-id -i ~/.ssh/
This way you'll registering your public key for the "username" user at "" server.

Alternative way

You can too copy your file content, login inside the server and append the file content to /home/username/.ssh/authorized_keys. The effect will be the same, but I think using ssh-copy-id is easier and quickly. Now when you try to login to server using ssh, like ssh you’ll have direct access! Thank you!

Update Oct 9 2013

An easy way to do that, without install nothing:

Check if exists

ssh-copy-id -i ~/.ssh/
This way you'll registering your public key for the "username" user at "" server.

If you found go to the next topic. If not do the following to create one public key:

cd ~/.ssh 
ssh-keygen -t rsa -C ""
  • 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]

After that:

ssh-add id_rsa

Copying your public key to remote server

cat ~/.ssh/ | ssh 'cat >> /home/user/.ssh/authorized_keys'


Subscribe to my Weekly Newsletter (on every Monday) and be emailed when a new blog post is published on my blog.

Published by

Junior Grossi

Senior PHP Engineer with TDD focus. Husband & Dad. Creator of Corcel PHP. Organizer of PHPMG. Software Engineer at InterNACHI. Loves coffee and music.