configure scp ssh

1.: Generate a key pair

  [user@rh user]$ ssh-keygen -t rsa
   Generating public/private rsa key pair.
   Enter file in which to save the key (/home/user/.ssh/id_rsa): --Prompt to enter the password during the generation process The key pair save location, press Enter directly, accept the default value
   Created directory '/home/user/.ssh'.
  
   Enter passphrase (empty for no passphrase): --Enter a password different from your password, press Enter directly, let It is empty. If you enter it, you will be prompted to enter the password for each subsequent remote connection.
   Enter same passphrase again:
  
   Your identification has been saved in /home/user/.ssh/id_rsa.
   Your public key has been saved in /home/user/. ssh/id_rsa.pub.
   The key fingerprint is:
   e0:f0:3b:d3:0a:3d:da:42:01:6a:61:2f:6c:a0:c6:[email protected]
   [user @rh user]$

where the public key is stored in ~/.ssh/id_rsa.pub and the private key is stored in ~/.ssh/id_rsa
Modify the permissions of the .ssh directory, "chmod 755 ~/.ssh"
   [user@rh user]$ chmod 755 ~/.ssh
 
Copy the id_rsa.pub public key to the machine to be accessed and save as
   ~/.ssh/authorized_keys and

you're done. When accessing other Linux machines with ssh scp sftp, you don't need to enter a password

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326494895&siteId=291194637