Common file transfer protocol (ftp, tftp, scp) and its characteristics

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_43608153/article/details/88880366

At work, we often have to relate to transfer files between file transfers, windows and windows, linux and linux, windows and linux, there is a good variety to choose from in the way. But nothing more than common so few.

Common file transfer protocols: FTP, TFTP, SSH, SCP

  1. FTP (English: File Transfer Protocol, abbreviated: the FTP)
    the FTP is an application layer protocol for transferring files in the network layer, based on TCP connection, using a client / server model.
    For ftp servers, commonly has two ports, one tcp port 21, the port is often used to connect the other is tcp port 20, the port is often used to transmit data.

    FTP supports two modes:

    1. Standard (PORT mode, active mode),
      the port PORT command 21 sent through the port 21 and establishing a client connection to the server, used to send commands, data acquisition client. PORT command contains the port number of the client receives the data. When transmitting data, the server is connected to the data transmission specified by the client port TCP 20 port. FTP server and client must establish a new connection used to transmit data.
    2. Passive (PASV, passive mode).
      Port channel establish control mode and the like, but after the establishment of transmission Pasv connect command. Pasv server receives the command to open a temporary port (port number greater than 1023 is less than 65535) and notifies the client transfer request data on this port, the client FTP server connected to this port, then the FTP server transmits data through this port.

    Disadvantages: FTP has extremely high latency, which means that the time between receiving the demand data from the request to start the first time, will be very long; and from time to time have to perform some lengthy login process.

    Command parameters:
    the FTP> ASCII # is set to transfer files in ASCII mode (the default value)
    the FTP> Bell # Each time a file transfer, alarm.
    The FTP> binary # set in binary mode to transfer files.
    The FTP> BYE to terminate the host # FTP process, and exit FTP management.
    the FTP> Case # when is ON, with MGET command to copy the file name to the local machine, all lowercase letters.
    the FTP> cd # with the UNIX CD command.
    the FTP> the cdup # go back one level.
    the FTP> # chmod change file permissions to the remote host.
    the FTP> use Close # remote FTP termination process, return to the FTP command status, all macro definitions are removed.
    the FTP> # delete the delete distal host file.
    the FTP> dir [Remote-directory] [local-file] # list the files in the current directory of the remote host. If there is a local file, it will write the results to a local file.
    the FTP> GET [Remote-file ] [local-file] # is transmitted from the remote host to the local host.
    FTP> [command] # output command interpretation Help.
    FTP> LCD # change the current working directory of the local host, if the default, the current passes to user's HOME directory.
    FTP> LS [Remote-directory] [local-FIL e] # with the DIR.
    FTP> macdef the # define macros.
    ftp> mdelete [remote-files] # delete a batch file.
    the FTP> mget [Remote-Files] # to receive a batch file from a remote host to the local host.
    the FTP> mkdir Directory-name # Create a directory in the remote host.
    ftp> mput local-files # to transfer the file number of the local host to the remote host.
    the FTP> Open host [Port] # to re-establish a new connection.
    the FTP> prompt # interactive prompt.
    the FTP> PUT local-file [ remote-file] # a local file transfer to the remote host.
    FTP> pwd # lists the current directory of the remote host.
    FTP> # quit with the BYE.
    FTP> the recv-Remote file [file-local] # same GET.
    ftp> rename [from] [to ] # change the file name of the remote host.
    the FTP> rmdir directory-# delete remote host name in the directory.
    the FTP> the send local-file [Remote-file] # with PUT.
    the FTP > status # shows the current state of FTP.
    FTP> # display system remote host system type.
    FTP> user-user name [password] [Account] # username otherwise re remote host.
    ftp>? [command] # with HELP. command name [command] specified in need of help. If you do not specify a command, ftp displays a list of all commands.
    ftp>! # ftp subsystem exit from the shell.

    Commonly used commands:
    Downloads: get readme.txt # download readme.txt file
    upload: put readme.txt # upload files

  2. TFTP (Trivial File Transfer Protocol, Trivial File Transfer Protocol)
    the TFTP protocol is TCP / IP protocol suite for simple file transfer between client and server, providing uncomplicated little overhead file transfer service. Port number is 69.

    TFTP protocol advantages
    1) TFTP can be used in those environments there is no TCP-UDP;
    2) TFTP Code share of small memory than FTP.

    TFTP protocol and FTP protocols different point
    1) TFTP protocol does not require verification authority clients, FTP requires client authentication;
    2) TFTP protocol generally used for LAN and remote UNIX computer, and common FTP protocol is used for the Internet ;
    3) the use of communication between the FTP client and server TCP, and used for communication between the client and server TFTP is UDP;
    4) TFTP only supports file transfer. In other words, TFTP does not support interactive, but not a huge set of commands. Most importantly, TFTP does not allow users to list the contents or negotiates with the server to determine which file is available.

    Command parameters:
    the -l is a local abbreviation, followed Client present in the source file name, or download the Client rename the file name.
    -r is the abbreviation for the remote, followed by a PC Server that is tftp server root directory of the source file name, file name, or after uploading Server renamed.
    -g is the abbreviation of get when downloading files,
    -p is an acronym put in, upload files,

    Commonly used commands:
    download things: tftp -g -r 1.txt -l 2.txt 192.168.1.1
    upload things: tftp -p -r 3.txt -l 2.txt 192.168.1.1

  3. Secure Shell SSH
    SSH protocol is based on the application layer protocol, providing security protocol for remote login session, and other network services.
    Traditional protocol (ftp, telnet, etc.) are all non-secure protocol, its working mechanism is easy to leak data. SSH and the data transmission process is encrypted, security higher.
    In fact, the main function of not using ssh protocol to transfer files, but remote login, because the ssh server and client will generate its own public key and a private key, the private key based on asymmetric encryption methods only they can get, only We need to give each other the public key to decrypt the data required in conjunction with public and private keys, so that the agreement largely to ensure data security.
    As for information security, I do not do here presented, and so there is time to sort out, release it.

    The greatest feature of the agreement is to secure ssh, ssh is not presented here describes the functions of its transfer files, but its high safety performance characteristics to extended SCP protocol.

  4. SCP (Secure Copy Protocol)
    scp to copy files and directories between Linux. Secure remote file copy based ssh login command. SSH tunnel connection is secure, and therefore based file transfer SCP protocol is safe.
    SCP protocol is divided into SCP Client and SCP Server. Whether it is server-side or client side, support the upload and download functions.

    Command parameters:
    -1: scp force command protocol SSH1
    -2: scp force command protocol SSH2
    -4: scp force command only using the IPv4 addressing
    -6: scp force command only IPv6 addressing
    -B: batch mode using (not transferred during interrogation password or phrase)
    -C: allow compression. (The -C flag to ssh, thus opening the compression)
    -p: retention modification time, access time and access to the original file.
    -q: does not display the transmission progress bar.
    -r: recursive copy the entire directory.
    -v: display output mode in detail. scp and ssh (1) will show the whole process of debugging information. This information is used for debugging connection, authentication, and configuration problems.
    -c cipher: cipher to encrypt the data transmission, this option is passed directly to ssh.
    -F ssh_config: ssh specify an alternate configuration file, this parameter is directly transmitted to ssh.
    -i identity_file: using the read key file transfer from the specified file, this parameter is directly transmitted to ssh.
    -l limit: the user can use a defined bandwidth, to Kbit / s units.
    -o ssh_option: If the parameter passing are accustomed to using ssh_config (5) is,
    -P Port: note the capital P, port is used to specify the data transfer port number
    -S program: a program specified encrypted transmission is used . This program must be able to understand ssh (1) options.

    Common Command:
    Command Format: scp srcusername @ srcip: srcpath / srcfile dstusername @ dstip: dstpath / dstfile
    wherein one of the parameters can be omitted according to upload and download manner, as follows:
    Upload: scp -r local_dir username @ servername: remote_dir
    Download: scp username @ servername: / path / filename / var / www / local_dir

Above my brief introduction to the two most commonly used file transfer protocol and a transmission tool, the other commonly used file transfer protocol there are many, such as sftp, ftps and so on, because I simply come into contact with, and there is no specific experience, so here trespass not with you, and we are interested can look to strengthen their own learning.

Guess you like

Origin blog.csdn.net/weixin_43608153/article/details/88880366
Recommended