Questo contenuto non è disponibile nella lingua selezionata.
20.7.3. Generating Key Pairs
If you do not want to enter your password every time you use
ssh, scp, or sftp to connect to a remote machine, you can generate an authorization key pair.
Keys must be generated for each user. To generate keys for a user, use the following steps as the user who wants to connect to remote machines. If you complete the steps as root, only root will be able to use the keys.
Starting with OpenSSH version 3.0,
~/.ssh/authorized_keys2, ~/.ssh/known_hosts2, and /etc/ssh_known_hosts2 are obsolete. SSH Protocol 1 and 2 share the ~/.ssh/authorized_keys, ~/.ssh/known_hosts, and /etc/ssh/ssh_known_hosts files.
Red Hat Enterprise Linux 5.10 uses SSH Protocol 2 and RSA keys by default.
Note
If you reinstall and want to save your generated key pair, backup the
.ssh directory in your home directory. After reinstalling, copy this directory back to your home directory. This process can be done for all users on your system, including root.
20.7.3.1. Generating an RSA Key Pair for Version 2 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Use the following steps to generate an RSA key pair for version 2 of the SSH protocol. This is the default starting with OpenSSH 2.9.
- To generate an RSA key pair to work with version 2 of the protocol, type the following command at a shell prompt:
ssh-keygen -t rsa
ssh-keygen -t rsaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Accept the default file location of~/.ssh/id_rsa. Enter a passphrase different from your account password and confirm it by entering it again.The public key is written to~/.ssh/id_rsa.pub. The private key is written to~/.ssh/id_rsa. Never distribute your private key to anyone. - Change the permissions of the
.sshdirectory using the following command:chmod 755 ~/.ssh
chmod 755 ~/.sshCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Copy the contents of
~/.ssh/id_rsa.pubinto the file~/.ssh/authorized_keyson the machine to which you want to connect. If the file~/.ssh/authorized_keysexist, append the contents of the file~/.ssh/id_rsa.pubto the file~/.ssh/authorized_keyson the other machine. - Change the permissions of the
authorized_keysfile using the following command:chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keysCopy to Clipboard Copied! Toggle word wrap Toggle overflow - If you are running GNOME or are running in a graphical desktop with GTK2+ libraries installed, skip to Section 20.7.3.4, “Configuring
ssh-agentwith a GUI”. If you are not running the X Window System, skip to Section 20.7.3.5, “Configuringssh-agent”.