Before you do this procedure you should set up your home network so the Raspberry PI always gets the same IP address. Do this in your router.
In this example I use jones1 as the name of the node and linda as the name of the mac user.
I also use 192.168.0.101 as the IP address of the node.
Replace these figures with your own Mac short username, nodename, and IP address.
ssh-keygen -t rsa -C "jones1 node access"
This command will result in a couple of queries:
Enter file in which to save the key: if you have never created one of these keys, just hit return to create the two files id_rsa.pub and id_rsa. If you have created one of these already on your Mac then hitting return may overwrite the existing key files. In that case type in a file name like node or jones1. I will assume you just hit return for the purposes of this example.
Enter passphrase: Enter a decent password.
You will only have to type this once for each Mac account or computer that you use.
I recommend writing down this password or saving it in a secure place outside of your Mac since you won't use it again until you decide
to connect to your Raspberry PI from a different computer, or if your Mac gets blown up.
Enter passphrase again: Type your password again.
When you hit return the machine will create the two files and print out some diagnostic info that should like something like this:
Your identification has been saved in /Users/linda/.ssh/id_rsa. Your public key has been saved in /Users/linda/.ssh/id_rsa.pub. The key fingerprint is: 67:42:d7:2b:35:2f:e9:0a:45:87:e5:8f:be:b3:37:89 jones1 node access The key's randomart image is: +--[ RSA 2048]----+ | . | | = | | . + * | | . o o B | | S = = o | | = + . | | . o. . | | . .E.+ | | . o+ . | +-----------------+
Now you need to put the public key onto the Raspberry PI.
cat ~/.ssh/id_rsa.pub This will cause the public key data to be printed in the Terminal window. Select the line of text starting with ssh and ending with the name string, jones1 node access in this case, and do a command-C copy of the text.
ssh over to firstname.lastname@example.org and log in. Substitute the IP address your Raspberry PI gets assigned. Now do cd .ssh then cat > authorized_keys then command-V paste, and then control-D which closes the cat. You should now open another terminal window and attempt to do ssh email@example.com to get to the node again.
A dialog box will open on the Mac asking you for your passphrase. Use the decent password you specified above, and check the box that says save password.
That should do it. You will not need a password to connect from that Mac and user to that Raspberry PI again. Try doing ssh firstname.lastname@example.org (or your IP address) again.
Now lets create an alias in your .bashrc file so you don't need to do the ssh command anymore.
First create an alias to show that we understand the syntax.
alias jones1="ssh email@example.com" and hit return.
Now if you type jones1 return, you will connect to your node.
If that works, let us make it permanent by writing the same command to your .bashrc file.
Get back to your Mac's terminal prompt by exiting from the Raspberry PI log-in, or by creating another Terminal window.
cat >> .bashrc
alias jones1="ssh firstname.lastname@example.org" Substitute the IP address your Raspberry PI gets assigned.
and then do control-D to close the cat.
If you log out and log back in to your Mac account, the alias will be automatically applied at log-in.
Now if you type jones1 you should get connected to your node with no fuss or bother.
If you want to change the text alias you type to get to the node, use a text editor like bbedit or TextWrangler or vi to edit the .bashrc file.