Record the data transmission method between local and server (uploading, downloading files)


1. Use the scp command to implement

Check server usage first

df -h
  • scp is the abbreviation of secure copy (secure copy). scp is a secure remote file copy command based on ssh login.
  • Equivalent to cp command + SSH. Its bottom layer is the SSH protocol, and the default port is 22, which is equivalent to using the ssh command to log in to the remote host first, and then performing the copy operation.
  • scp is encrypted, rcp is unencrypted, and scp is an enhanced version of rcp.

window opens cmd inputscp View as shown below (mac opens terminal input)
Insert image description here

  • grammar
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 [...] [[user@]host2:]file2

  • Simple writing:
scp [可选参数] file_source file_target 

Parameter Description

  • -1: Force the scp command to use protocol ssh1
  • -2: Force the scp command to use protocol ssh2
  • -4: Force the scp command to only use IPv4 addressing
  • -6: Force the scp command to only use IPv6 addressing
  • -B: Use batch mode (do not ask for transfer password or phrase during transfer)
  • -C: Enable compression. (Pass the -C flag to ssh to turn on compression)
  • -p: Keep the modification time, access time and access permissions of the original file.
  • -q: Do not display the transfer progress bar.
  • -r: Recursively copy the entire directory.
  • -v: Display output in verbose mode. scp and ssh(1) will display debugging information for the entire process. This information is used to debug connection, authentication, and configuration issues.
  • -c cipher: Encrypt data transmission with cipher. This option will be passed directly to ssh.
  • -F ssh_config: Specifies an alternative ssh configuration file, this parameter is passed directly to ssh.
  • -i identity_file: Read the key file used during transfer from the specified file. This parameter is passed directly to ssh.
  • -l limit: Limit the bandwidth that users can use, in Kbit/s.
  • -o ssh_option: If you are used to using the parameter passing method in ssh_config(5),
  • -P port: Note the capital P. port is the port number used for specifying data transmission.
  • -S program: Specify the program used for encrypted transmission. This program must be able to understand the options of ssh(1).

Example

The following IP is the server IP address

If the server is added root@ you only need to enter the password, if not, you need to enter the username and password

  • Upload files to the server
    For example, upload local /Users/projectdirectories to the server /project/folders
scp /Users/project root@ip:/project/
  • Download server files
    For example, download server /project/demo.txt files to local /Users/projectdirectory
scp root@ip:/project/demo.txt /Users/project
  • Folder upload and download, just add after scp in the above command, that is, -rscp -r [本地/服务器路径] [本地/服务器路径]

scpCommands can be created according to actual needs .shScripts to achieve fast downloading and uploading

illustrate

  • 1. If the remote server firewall has set a specified port for the scp command, we need to use the -P parameter to set the port number of the command. The command format is as follows:
#scp 命令使用端口号 4588
scp -P 4588 [email protected]:/usr/local/sin.sh /home/administrator
  • 2. When using the scp command, make sure that the user you use has permission to read the corresponding files on the remote server, otherwise the scp command will not work.

2. Use tools to implement

windows system

  • MobaXterm
    As shown in the picture, click on the upper left cornerSession, and then select the corresponding server type, (host-server ip address, username-user name)
    Insert image description here

  • securecrt

  • xshell (combined with xftp plug-in)

  • putty

  • powershell

Apple system

  • ZenTermLite
  • ZenTerm,

如有启发,可点赞收藏哟~

Guess you like

Origin blog.csdn.net/weiCong_Ling/article/details/134626623