Setting Up a Public Authentication Key in Terminal

by | Feb 16, 2012

I just did this, and I don’t want to forget how. This explains how to set up a public authentication key and make it executable

First, create your public key. Open the terminal. Navigate to the directory where you want to keep your key. You will have to run your key from this folder once you’re done. In my case, it’s Users/MyName

Now, enter:

It will ask you where to store the key – hit enter for the current directory. You will be prompted for a passphrase. Hit enter if you don’t want to use one, then hit enter again to confirm.

You should see:

Then a string of digits that are the digital representation of your public key, and some neat ASCII art that is a visual representation of same.

Next, upload your key to your server with scp:

Enter your server password when prompted.

You’re good to go. Now you can connect with ssh like so:

And it won’t bug you for a password. But that’s still kind of a lot of typing. Let’s make this an executable.

Disconnect from the server with:

Create a text file using vim:

Type ” i ” to get into insert mode, then:

Next, make it executable.

Done deal. Now you can run this command:

And you will connect to the server without any further fuss.