Linux SCP Usage Details

Source: Internet
Author: User
Tags scp command ssh port

Generally, there are three common methods for data exchange or data migration between a local network and a remote network: FTP and wget/fetch, rsync uses rysync for large-scale data migration, followed by fetch/wget. The longest is FTP, and the slowest is FTP. in the past few days, ssh SCP is used for data migration during busy data migration. The speed and effect are good. In particular, many servers change the default ssh port 22 to a special port for security purposes. So. When using SCP or SFTP, you must specify the port through which to migrate data. Now, write down the SCP command for this special port.

SCP-P port user @ serverip:/home/user/filename

The preceding port P is the parameter, and the port user is the SSH user serverip is the remote server IP address or domain name, /home/user/filename is the name of the remote server/home/user/filename is the name of the Local Service server. This command is used to copy the remote filename to the local directory.

SCP has a huge role. For detailed usage, you can use man SCP or SCP-help. The following is a detailed description of SCP...
The SCP command of Linux can copy files and directories between Linux;

============================
SCP command
============================
SCP can copy files between two Linux Hosts;

Basic command format:
SCP [optional parameter] file_source file_target

======
Copy from local to remote
======
* Copy a file:
* 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

The user name is specified for the 1st and 2nd commands. After the command is executed, you need to enter the password. Only the remote directory is specified for the 1st command. The file name remains the same, and the file name is specified for the 1st command;
No user name is specified for the 3 and 4 commands. After the command is executed, enter the user name and password. Only the remote directory is specified for the 3rd commands. The file name remains the same and the file name is specified for the 4th commands;
* Routine:
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/002.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/002.mp3

* Copy directory:
* Command format:
SCP-r local_folder remote_username @ remote_ip: remote_folder
Or
SCP-r local_folder remote_ip: remote_folder

1st user names are specified, and the password needs to be entered after the command is executed;
2nd user names are not specified. After the command is executed, enter the user name and password;
* Routine:
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, that is, there is a remote ../Others/music/directory after the copy.

======
Copy from remote to local
======
From remote to local, you only need to replace the last two parameters of the local command to remote;

For example:
SCP root@www.cumt.edu.cn:/home/root/Others/music/home/SPACE/music/ithers
SCP-r www.cumt.edu.cn:/home/root/Others/home/SPACE/music/

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.