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
The User home directory (home) and ~/.ssh, and ~/.ssh/authorized_keys for the remote host are also set to the appropriate permissions.
Step 1:
Using Ssh-key-gen to create public keys and keys on the local host
[Email protected]$ ssh-keygen-t RSA (or DSA)
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 have been saved in
/home/jsmith/.ssh/id_rsa.
Your public key have 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
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 into the
Machine, with―ssh. Remote-host ' ‖, and check in:
. Ssh/authorized_keys to
Make sure we haven ' t added extra keys so you weren ' t expecting.
Note
Ssh-copy-id append 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 Nov 16
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