SSH KEY Authentication Linux How To


If you want to have a workstation with (Linux or Mac) to SSH into a server without a passphrase, this is how you can do it.

On your workstation generate a “key” with ssh-keygen


This will create a id_rsa and under your home dir/.ssh

mac : /Users/your_account/.ssh/
linux : /home/your_account/.ssh/

id_rsa : this is your private key, you keep it safe on your machine!! : this is the key you copy to each server you want to authenticate without a password.

Copy the to the server, you can use scp for that

scp /Users/your_account/.ssh/

WARNING : the must be copy under the account you want to authenticate on the server. So if normally on your server you log in as root (not recommend), you will copy the under the root.

WARNING2 : I strongly suggest you rename the on the target for because a file can already exist and might be overwritten.

Now. The is on the server.
SSH to the server (yes with your credential, for the last time ;))

You need to import your key into a special file called authorized_keys

with the scp command I copied the file into the root.

cd /root/.ssh/

now import the into the authorized_keys

cat >> authorized_keys

Quit your current ssh.

Retry ssh with :


No password should be asked.


Leave a Reply

Your email address will not be published. Required fields are marked *