SSH Public Key Overview

Local Remote

ssh-keygen -t rsa

The option -t rsa says that you want to generate an SSH2 key using RSA authentication.

This generates the following files under ~user/.ssh/

id_rsa Keep this secret!
id_rsa.pub Copy this to Remote

 
  Append id_rsa.pub key to ~user/.ssh/authorized_keys
ssh user@remote  
   
   
   

 

Things that often cause you to fail.

The SSH2 protocol specifies a format for storing public keys. Some SSH servers (such as ssh.com's) require a public key in this format in order to accept authentication with the corresponding private key. Others, such as OpenSSH, use a different format. I don't know what to do about this.

This is the cause of much grief and annoyance.

When cutting and pasting the public key BEWARE that it should be a single line. If you cut and paste from a terminal window then it is likely that you will get newline characters added where your terminal wrapped the line. If you use vi then the line may wrap and APPEAR to be multiple lines, but it is really one single line. When you paste it to a new window it may look the same, but the copy will likely contain newline characters. This will not work. Be careful when copying keys and appending to the authorized_keys2 file.

This is the cause of much grief and annoyance.

Make sure you are using the right version. Earlier versions of OpenSSH uses two files, authorized_keys and authorized_keys2. Secure SSH uses something else with keys in an entirely different format.

Why? Why? Why?