Mac – Connect to SSH with RSA (No Passwords)

Apps-Terminal-Ssh-icon-2Not sure at what OS X version this has been possible from. Here we will see how to set up the mac for password less ssh connection with RSA certificate. This will make your daily terminal life at bit easier, and also more secure as you can disable password logins on your root user (if you allow remote root connections).

First we need to create two RSA certificates. One public key, and one private key. The public key contains the information you put on the remote server. And the private key is the one you use to authenticate to the remote server.

Open Terminal, or go to your home folder if it´s already open.
Create a folder to save the certificates.
mkdir .ssh

If you have used SSH before from that mac, the folder already exist.
So just change directory to .ssh
cd .ssh

Then we will create the keys.
ssh-keygen -b 2048 -t rsa -f id_rsa -P “”

-b 2048 means we will use 2048 bit encryption
-t rss means we will create rsa key pair
-f id_rsa is the filename we will like to use
-P “” means we have no password in the RSA certificate

I haven´t found a mac version of the linux tool ssh-copy-id, so we will have to do this manually. Chances are you key file on your remote system is empty, since you´re reading this article.

You are still in the .ssh directory on your mac. If you got the .ssh directory on your remote system already, just delete the mkdir .ssh; from the line below.
cat id_rsa.pub | ssh john@192.168.1.80 “mkdir .ssh; cat >> .ssh/authorized_keys”
This one liner is basically the same as the ssh-copy-id command in linux.

Now you can try to login to your remote system, and it should´t ask for any passwords. If it does, I would check the authorised_keys file in the remote system. Should be in a folder called .ssh in your home directory.

Happy sshing!

About Author

Related Posts

can't set locale

Can’t set locale; make sure $LC_* and $LANG are correct!

Can’t set locale; make sure $LC_* and $LANG are correct! This suddenly appeared on all my servers one day after some updates. All of them were running…

Xcode 9 iOS icon sizes

Xcode 9 iOS icon sizes overview

Xcode 9 iOS icon sizes overview Xcode 9 iOS icon sizes overview. They keep adding more and more icon sizes. Xcode 9 has the most icon sizes…

how to uninstall unity

How to uninstall Unity on Mac

How to uninstall Unity on Mac This is how to uninstall Unity on Mac. Follow these simple steps and delete the following folders or files. 1. /Applications/Unity…

Xcode 9 uiimage image not shown

Xcode 9 uiimage image not shown

Xcode 9 uiimage image not shown Working on some ios apps created with Xcode 8 and your images don’t show after upgrading to Xcode 9? Took me awhile…

how to find minecraft on mac

How to find minecraft on mac

How to find minecraft on mac How to find minecraft on mac is quite easy. There is two places you need to look. The Minecraft game itself…

Xcode 8 iOS icon sizes overview

Xcode 8 iOS icon sizes overview Xcode 8 iOS icon sizes overview. There are even more icon sizes since Xcode 7. And it can be an extra challenging…

Leave a Reply