Using SCP commands to pass files between Linux operating systems

Source: Internet
Author: User
Tags scp command secure copy

I. On the SCP

SCP is the abbreviation for the English secure copy program , which is used primarily to copy files over the network between two hosts. SCP uses ssh protocol for data transfer, and its authentication method and security are consistent with ssh .

Second, The installation of SSH client

if prompted during use, " -bash:scp:command not found"indicates that the system has not installed the SSH client software and needs to perform yum install openssh-client s command to install

iii. How to use the SCP command

1 ,SCP basic syntax for commands

SCP [Options] [[Email protected]]host1:]file1 ... [[Email Protected]]host2:]file2

2 ,SCP common parameters for commands

-1 enforce SCP Command usage protocol SSH1

-2 enforce SCP Command usage protocol SSH2

-4 forced use of IPV4 address.

-6 forced use of IPV6 address.

- b use batch mode (transfer password or phrase is not asked during transfer)

- C When using this parameter, ssh The protocol opens the compression option.

- P Specifies the port of the remote host. Note that is the capital letter "P".

- R recursively replicates data within a folder. This option is used in the Copy folder.

- P preserves the original file's modification time, access time, and access rights.

- Q The transfer progress bar is not displayed.

- v show the output in detail. SCP and ssh (1) will display debugging information for the entire process. This information is used to debug connections, authentication, and configuration issues.

- C cipher The data transfer is encrypted with cipher , and this option is passed directly to ssh .

- F Ssh_config Specifies an alternative ssh configuration file that is passed directly to the ssh .

- I. Identity_file The key file used to read the transfer from the specified file, which is passed directly to ssh .

- L Limit Limit the bandwidth that users can use to kbit/s as the unit.

- o ssh_option If you are accustomed to using ssh_config (5) the method of parameter passing in the

- S program Specifies the program that is used to encrypt the transfer. This program must be able to understand the options for ssh (1) .

iv. Examples of use of SCP commands

1 , copying files from a local host (folder) to a remote host

the command format is ( - R parameters for recursive replication folders):

SCP (–r) local_file [email Protected]_ip:remote_folder

Example 1 :

[[Email protected] ~] #scp/tmp/temp.txt [email protected]:/tmp/temp.txt

Description: The local host file The /tmp/temp.txt is copied to the/ TMP folder on the remote host 192.168.1.2 (the remote host user is root)

Example 2 :

[[Email protected] ~] #scp –r/tmp [email protected]:/tmp

Description: The local host folder All files in/tmp are copied recursively to the/ tmp folder on the remote host 192.168.1.2 (the remote host user is Root )

2 , copying files (clips) from a remote host to a local host

SCP (–r) [Email Protected]_ip:remote_folder local_file

3 , copying files between two remote hosts (clip)

SCP (–r) [Email protected]_ip:remote_folder

Five, the use of the process may encounter problems and solutions

1 , the "license denied" issue caused by user file permissions

Example:

username1 is the local machine username2 is a remote

# scp/home/files [email protected]:/home/files2 [email protected] ' s password:
SCP:/home/files2:permission denied

Description: This is because the user of the remote host username2 no /home/files2 . Write permission for the file. You can use the following workarounds:

Execute on local server:

#scp/home/files [Email protected]:/tmp

Then execute on the remote server:

#mv/tmp/files/home/files

or you can configure it on a remote host /home folder adds user username2 the Write permission.

2 ,ssh "License denied" issue due to user rights configuration in the Protocol

Example:

#scp/www/xinpindao [email protected]:/tmp Remote machine User Root

[email protected]' s Password:

Permission denied, please try again.

Description: This is due to ssh service shutdown root the user's logon rights are caused. You can use the following workarounds:

to modify root ssh access, which modifies the /etc/ssh/sshd_config file Permitrootlogin no to permitrootlogin Yesandthen Restart the SSH service

#/etc/init.d/sshd restart

Reprint Address: http://myblog.jyc.edu.cn/?p=151

(go) Use SCP commands to pass files between Linux operating systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.