Ssh-keygen generates a public and private key pair.
Ssh-copy-id The local public key is copied to the remote machine's Authorized_keys file, Ssh-copy-id can also let you have to the remote machine home, ~./SSH, and ~/.ssh/authorized_ The right to Keys
using Ssky-keygen and Ssh-copy-id in the example below, you can log in to a remote Linux host with a simple setup of 3 steps without entering a password.
Ssh-keygen create public keys and keys.
The Ssh-copy-id copies the local host's public key to the remote host's Authorized_keys file.
Ssh-copy-id also sets the appropriate permissions for the remote host's user home directory (home) and ~/.ssh, and ~/.ssh/authorized_keys.
Step 1: Create a public key and key on the local host with Ssh-key-gen
[email protected]$ ssh-keygen-t RSA
enter file in which to save the key (/HOME/JSMITH/.SSH/ID_RSA): [Enter key]
Enter passphrase (empty for no passphrase): [Press Enter key]
enter same passphrase again: [pess enter key]
Your identification has been saved In/home/jsmith/.ssh/id_rsa.
Your Public Key has been saved in/home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9
[email protected]
Step 2: Use Ssh-copy-id to copy the public key to the remote host
[email protected]$ ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected]
[email protected] ' s password:
Now try logging to the machine, with―ssh. Remote-host ' ‖, and check in:
. Ssh/authorized_keys to make sure we haven ' t added extra keys, you weren ' t expecting.
[Note: Ssh-copy-id appends the key to the. Ssh/authorized_key on the remote host.]
Step 3: Log in directly to the remote host
[email protected]$ ssh remote-host
Last Login:sun-17:22:33 from 192.168.1.2
[Note: SSH does not ask for a password.]
[Email protected]$
[Note: You are now logged on to the remote host]
Ssky-keygen + ssh-copy-id login remote Linux host without password