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]
Then do what you need to do, like copy{.
Scp-r-P crawler-general/[email protected]:/home/crawler/
Scp-r-P crawler-general/[email protected]:/home/crawler/
Scp-r-P crawler-general/[email protected]:/home/crawler/
Scp-r-P crawler-general/[email protected]:/home/crawler/
Scp-r-P crawler-general/[email protected]:/home/crawler/
}
Linux_ssky-keygen + ssh-copy-id login remote Linux host without password