Mac uses SCP to upload and download files

What is scp?

scp is the abbreviation of secure copy. It is a command used to copy files remotely under Linux. Similar commands are cp, but cp is only copied locally and cannot be cross-server, and scp transmission is encrypted.

What is the use of scp?

1. We need to obtain a file on the remote server. The remote server has neither an ftp server configured, nor a web server enabled, nor is it shared. When the file cannot be obtained through conventional channels, only the scp command can be used to easily achieve the goal. .

2. We need to upload the files on this machine to the remote server. The remote server does not have the ftp server or sharing enabled, and it cannot be uploaded through conventional means. You can easily achieve the goal through the scp command.

How to use scp

Port capital-P is a parameter, 2222 means the port after changing the SSH port. If the SSH port is not changed, you do not need to add this parameter. By default, port 22 of SSH will be used.

1. Get files on remote server
scp -P 2222 [email protected]:/home/favicon.ico /Users/xiao/Documents/favicon.ico

[email protected] means using the root user to log in to the remote server 192.168.191.32,

/home/favicon.ico represents the file on the remote server,

/Users/xiao/Documents/favicon.ico represents the path and file name saved locally.

2. Get the directory on the remote server
scp -P 2222 -r [email protected]:/home/ /Users/xiao/Documents/

-r: The parameter indicates recursive copy (ie copy the files and directories under the directory)

[email protected] means using the root user to log in to the remote server 192.168.191.32,

/home/ represents the directory on the remote server,

/Users/xiao/Documents/ represents the directory path saved locally.

3. Upload local files to the server
scp -P 2222 /Users/xiao/Documents/favicon.ico [email protected]:/home/favicon.ico

/Users/xiao/Documents/favicon.ico represents the path and file name saved locally.

[email protected] means using the root user to log in to the remote server 192.168.191.32,

/home/favicon.ico represents the file on the remote server,

4. Upload the local directory to the server
scp -P 2222 -r /Users/xiao/Documents/ [email protected]:/home/

-r: The parameter indicates recursive copy (ie copy the files and directories under the directory)

[email protected] means using the root user to log in to the remote server 192.168.191.32,

/home/ represents the directory on the remote server,

/Users/xiao/Documents/ represents the directory path saved locally.

5. Several parameters that may be useful:

-v: Same meaning as -v in most linux commands, used to display progress. It can be used to check connection, authentication, or configuration errors.

-4: Forcibly use IPV4 address.

-6: Forcibly use IPV6 address.

Guess you like

Origin blog.csdn.net/qinyikl/article/details/78598280