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: https://github.com/beautifulcode/ssh-copy-id-for-OSX
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/id_rsa.pub firstname.lastname@example.org This way you'll registering your public key for the "username" user at "example.com" server.
You can too copy your id_rsa.pub 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 email@example.com you'll have direct access! Thank you!
Update Oct 9 2013
An easy way to do that, without install nothing:
Check if id_rsa.pub exists
cd ~/.ssh ls
If you found id_rsa.pub go to the next topic. If not do the following to create one public key:
cd ~/.ssh ssh-keygen -t rsa -C "firstname.lastname@example.org"
- 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]
Copying your public key to remote server
cat ~/.ssh/id_rsa.pub | ssh email@example.com 'cat >> /home/user/.ssh/authorized_keys'