How to use linux ssh upload and download file command SCP

In the linux environment, we can download from the server or upload files from the local to the server through the SCP command .

SCP is Security Copy, which is a remote file copy command implemented based on SSH login .

Command parameters: -r: recursively copy the entire folder

-i : Ask whether to overwrite

-p : keep the file

The specific usage method is as follows:

  1. Upload files from local to server:

scp local file path username@ServerIP: save file address

Such as: scp /home/test.zip [email protected] :/opt/test/, upload the test.zip file under the local /home to the /opt/test directory of the server at 192.168.0.152; the input is correct during the process User password, wait for the copying to complete.

  1. Upload the folder to the server

SCP -r local folder path user@serverIP: save file address

Such as: scp -r /home/test [email protected] :/opt/test/, upload the test folder under the local /home to the server /opt/test directory of 192.168.0.152; enter the correct User password, just wait for the copying to complete.

  1. Download the file locally

scp user @serverip: the path of the file to be downloaded and the local storage directory

For example: scp [email protected] :/opt/test.zip /home/test, that is, log in as the root user, and download the test.zip file under /opt to the local /home/test directory.

  1. Download folder to local

scp -r user@serverip: folder path to download local save path

For example: scp [email protected] :/opt/test/ /home/test Log in as root user, download the test folder under /opt to the local /home/test directory.

Guess you like

Origin blog.csdn.net/yeyuningzi/article/details/129731625