Scp copying between Linux hosts without entering a password

  
                  

Copy the ssh public key file of your local host user to the ~/.ssh/authorized_keys file of the remote host user, assuming the local host linux (10.1.1.1), remote host linux (10.1.1.2)


First, the user in the linux100 host


Run


#ssh-keygen -t rsa


Results


Generating public/private rsa key pair.


Enter file in which to save the key (/home/.username/ssh/id_rsa):#Enter


Enter passphrase (empty for no passphrase):#Enter


Enter same passphrase again:#Enter


Your identification has Been saved in /home/.username /.ssh/id_rsa.


Your public key has been saved in /home/.username /.ssh/id_rsa.pub.

< BR>The key fingerprint is:


38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost


Generating RSA keys:


Key generation complete.


Two files will be generated in the user directory ~/.ssh/, id_rsa , id_rsa.pub


Second, put linux (10.1.1.1) on the host The id_rsa.pub file is copied to the .ssh directory under the root user directory of the linux (10.1.1.2) host, and renamed to authorized_keys


:


/Root/.ssh/authorized_keys


This will copy the file to linux (10.1.1.2) on the linux100 host and will not prompt for the password, directly copied. vice versa!


Three, copy file or directory command:


Copy files:


(1) Copy local files to remote


scp file [email protected]: remote path


(2)copy files from remote to local


scp -- [email protected]: Filename local path


Copy directory:


(1) Copy local directory to remote


scp -r directory [email protected]: remote path


(2) Copy the directory back to the local remote


scp -r [email protected] .1.2: Directory name local path.

Copyright © Windows knowledge All Rights Reserved