Generating RSA Keypairs on Mac OS X for a *nix web-server

I’m sure there are many of you who have long been comfortable with RSA keypairs, so I post this as much for my own reference, as for those like me who stumble around the Internet trying to find coherent instructions on how to do this. These instructions work for OS X 10.4 — not sure about other versions or *nixes. I plan to apply them to securing SSH on my iPhone for easier file transfers though.
Step 1: Open Terminal
Usually found in the Utilities folder of Applications (but if you didn’t know that already, this might not be the right topic for you!)
Step 2: Create your public/private key pair on your local computer

  • At the command prompt type: ssh-keygen -t rsa
  • Hit enter to accept the default file name and location

Step 3: Copy your public key contents into the “authorized_keys2” file on the remote server

  • Type: ssh username@remoteserver.com 'cat >> ~/.ssh/authorized_keys2' < /Users/Youruser/.ssh/id_rsa.pub
  • Enter your FTP password for the remote server when prompted
    • If the file didn’t already exist on the remote server, it will be created, don’t worry.

Step 4: SSH at will!
You will never need a password from your account on your local computer again! Note that you’ll need a public key provided for each client computer/computer account you want to use to connect to the server.