Users must generate a public/private key pair when their site implements host-based authentication or user public-key authentication. For additional options, see the ssh-keygen(1) man page.
Before You Begin
Ask your system administrator whether host-based authentication is configured.
mySystem% ssh-keygen -t rsa Generating public/private rsa key pair. …
where –t is the type of algorithm, either rsa, dsa, or rsa1.
By default, the file name id_rsa, which represents an RSA v2 key, appears in parentheses. You can select this file by pressing the Return key or provide an alternative file name.
Enter file in which to save the key (/home/username/.ssh/id_rsa):<Press Return>
The file name of the public key is created automatically by appending the string .pub to the name of the private key file.
This passphrase is used for encrypting your private key. A null entry is strongly discouraged. Note that the passphrase is not displayed when you type it in.
Enter passphrase (empty for no passphrase): <Type passphrase>
Enter same passphrase again: <Type passphrase> Your identification has been saved in /home/username/.ssh/id_rsa. Your public key has been saved in /home/username/.ssh/id_rsa.pub. The key fingerprint is: 0e:fb:3d:57:71:73:bf:58:b8:eb:f3:a3:aa:df:e0:d1 username@my System
% ls ~/.ssh id_rsa id_rsa.pub
At this point, you have created a public/private key pair.
You can now log in to the remote host. For details, see How to Log In to a Remote Host With Secure Shell.
% cat /etc/ssh/ssh_host_dsa_key.pub | ssh RemoteHost \ 'cat >> ~./ssh/known_hosts && echo "Host key copied"'
Enter password: <Type password> Host key copied %
Type the following command on one line with no backslash.
mySystem% cat $HOME/.ssh/id_rsa.pub | ssh myRemoteHost \ 'cat >> .ssh/authorized_keys && echo "Key copied"'
When the file is copied, the message “Key copied” is displayed.
Enter password: Type login password Key copied mySystem%
See How to Reduce Password Prompts in Secure Shell. For more information, see the ssh-agent(1) and ssh-add(1) man pages.