Use of SCP
Replicate from local to remote
Command basic format:
SCP [Optional parameters] Local filename remote user name @ Remote address: Remote file or directory
Copy file Example:
Scp/home/backup.zip Root@www.example.com:/home/others/backup
Scp/home/backup.zip Root@www.example.com:/home/others/otherbackup.zip
The first is the local file Backup.zip sent to the remote backup directory.
The second is the local file Backup.zip sent to the remote Otherbackup.zip file.
Copy Directory Example:
Scp-r/home/backup root@www.example.com:/home/others/
Replicate local directory Backup to remote directory others
From remote replication to local
Command basic format:
SCP [Optional parameters] remote user name @ Remote address: Remote file or directory local file name
Example:
SCP Root@www.example.com:/home/others/bakcup.zip/home/newbackup.zip
Scp-r root@www.example.com:/home/backup/home/other/
The first is to download the remote file Backup.zip to the local file newbackup.zip.
The second is to download the remote directory Bakcup to the local directory.
SCP Optional Parameters:
Parameter explanation
-V is the same as the-V meaning in most Linux commands, and is used to show progress. Can be used to view connections, authentication, or configuration errors.
-C Enable Compression option
-P Select the port. Note-P has been used by RCP.
-4 forcibly use IPV4 address.
-6 forcibly use IPV6 address.
Replicate from local to remote
======
* Copy files:
* Command format:
SCP Local_file Remote_username@remote_ip:remote_folder
Or
SCP Local_file Remote_username@remote_ip:remote_file
Or
SCP Local_file Remote_ip:remote_folder
Or
SCP Local_file Remote_ip:remote_file
1th, 2 specified the user name, the command needs to enter the password after the execution, the 1th specified only the remote directory, the file name unchanged, the 2nd specified the filename;
3rd, 4 did not specify the user name, the command needs to enter the user name and password, the 3rd specified only a remote directory, the file name unchanged, the 4th specified the filename;
Example
Scp/home/space/music/1.mp3 Root@www.cumt.edu.cn:/home/root/others/music
Scp/home/space/music/1.mp3 Root@www.cumt.edu.cn:/home/root/others/music/001.mp3
Scp/home/space/music/1.mp3 Www.cumt.edu.cn:/home/root/others/music
Scp/home/space/music/1.mp3 Www.cumt.edu.cn:/home/root/others/music/001.mp3
* Copy directory:
* Command format:
Scp-r Local_folder Remote_username@remote_ip:remote_folder
Or
Scp-r Local_folder Remote_ip:remote_folder
The 1th specifies the user name, the command needs to enter the password after the execution;
The 2nd does not specify the user name, the command needs to enter the user name and password after execution;
Example
Scp-r/home/space/music/root@www.cumt.edu.cn:/home/root/others/
Scp-r/home/space/music/www.cumt.edu.cn:/home/root/others/
The above command copies the local music directory to the remote others directory, which is remotely available after replication. /others/music/Directory
======
From remote replication to local
======
From remote to local, as long as the following 2 parameters of the command will be copied from the local to the remote order can be replaced;
For example:
SCP Root@www.cumt.edu.cn:/home/root/others/music/home/space/music/1.mp3
Scp-r www.cumt.edu.cn:/home/root/others//home/space/music/
The simplest applications are as follows:
SCP local username @IP address: filename 1 remote username @IP address: filename 2
[local username @IP address:] You may want to enter the password for the remote user name without entering it.
Several parameters that may be useful:
-V This is the same as the-V in most Linux commands to show progress. Can be used to view connections, authentication, or configuration errors. The
-C enables compression options.
-P Select the port. Note-P has been used by RCP.
-4 forcibly uses the IPV4 address.
-6 forcibly uses the IPV6 address.
The use of Linux SCP commands should be able to meet your replication usage for Linux files and directories.
about the security aspects of the SCP
Copy Local files to a remote machine
scp/etc/lilo.conf k@net67.ee.oit.edu.tw:/home/k
will place the local/etc/lilo.conf This file copy to net67.ee.oit.edu.tw, user K's home directory.
Copy files on remote machine to local
SCP k@net67.ee.oit.edu.tw:/etc/lilo.conf/etc
will net67.ee.oitdu.tw/etc/lilo.conf files Copy to the local/etc directory.
Keep properties from source Host file
Scp–p k@net67.ee.tw:/etc/lilo.conf/etc
If you want to use a specific port for scp–p (uppercase) such as SCP–P 1234 k@net67.ee.tw :/etc/lilo.conf/etc
You must pay attention to whether the user's permissions can read files on the remote, and if you want to know more about how to use the SCP, check out the SCP manual.
Ssh-keygen
Generate the public key (Pulib key) and private key, in order to protect SSH online security, when SSH SHD server, will exchange the public key, the system will check the/etc/ssh_know_hosts stored in the key, if the client is found to use this Key produces a randomly generated session key to the server, both ends with this key to continue to complete the SSH remaining phase.
It generates identity.pub, identity two files, private keys are stored in identity, public keys are stored in identity.pub, and then the SCP is used to identity.pub copy To the home directory of the remote machine. SSH Authorized_keys. Ssh/authorized_keys (This Authorized_keys file corresponds to the rhosts file of the protocol), after which the user can log in without the password. RSA authentication is definitely more secure and reliable than rhosts authentication.
Perform:
SCP Identity.pub K@linux1.ee.oit.edu.tw:.ssh/authorized_keys
If you do not enter a password when using Ssh-keygen to generate a key pair, you can login to linux1.ee.oit.edu.tw from net67.ee.oit.edu.tw as shown above without entering a password. Here, the password entered here can be different from the password of the account, you can not enter the password.