Upload and download using SSH software (using Sz and RZ commands)

Source: Internet
Author: User
Tags file transfer protocol

1. Brief Introduction

Generally, when you use SSH to manage remote Linux servers, you often need to interact with local files. Of course, we can use ftp, such as through filezilla client software. However, using the built-in upload and download functions of SSH software (securecrt and xshell) is undoubtedly the most convenient and convenient. Generally, file transfer protocols supported by SSH include ASCII, XMODEM, and zmodem.

Rz, SZ is a command line tool for zmodem file transmission in Linux/Unix and windows.

  1. First, you need to install Rz. sz on your Linux (centos, UBUNTU.

  2. Secondly, windows must support the zmodem Telnet/ssh client (xshell support, as if putty does not support). securecrt can be used to log on to Unix/Linux Hosts (either telnet or SSH)

  3. Run the RZ command to receive the file. xshell will pop up the file selection dialog box. After selecting the file, close the dialog box and upload the file to the current directory in Linux. If you want to upload a file, click the file and drag it to X-shell.

  4. Run the command SZ file to send the file to Windows (the saved directory can be configured), which is much easier than the FTP command, and the server no longer needs to enable the FTP service.


2. File Transfer Protocol

File Transfer is the main form of data exchange. To ensure correct identification and transmission of files during file transfer, we need to establish a unified transfer protocol between the two computers. This Protocol includes File identification, transfer start and end times, and error judgment and correction. Common transmission protocols include the following:

  • ASCII: This is the fastest transmission protocol, but it can only transmit text files.

  • XMODEM: this old transmission protocol is slow, but the CRC error detection method can achieve a Transmission Accuracy of up to 99.6%.

  • Ymodem: This is an improved version of XMODEM. It uses a 1024-bit segment for transmission, which is faster than XMODEM.

  • Zmodem: zmodem uses Streaming Transmission Mode to achieve fast transmission speed. It also provides functions such as automatic change of segment size, resumable data transfer, and fast error detection.This is currently the most popular file transfer protocol..


3. Install lrzsz on Linux

Only the SSH client software does not support file transfer. We have to install the corresponding software on our Linux server to support these file transfer protocols. On Linux, lrzsz completes this task. We use the sz/Rz commands to send/receive files respectively. If the lrzsz package is not installed in our system, an error is reported.

[[email protected] ~]# rz-bash: rz: command not found## CentOS/RHEL[[email protected] ~]# yum -y install lrzsz## Ubuntu# sudo apt-get install lrzsz


4. Understanding memory

Here, I use the following methods for understanding and memorizing Sz and RZ (it is often easy to confuse ):

  • In SZ, "S" means "send" and tells the client that "I (server)" wants to send the file "send to cilent", which is equivalent to "Download" on the client.

  • The R in RZ indicates received, and tells the client that the client is uploading the received ed by cilent file.

Remember, whether it is send or received,Actions are initiated on the server.. We are used to uploading or downloading, but it is not necessary. To use these two commands, you only need to think about whether to send the file from the server or receive it from the client.


5. Simple usage

  • SZ usage: Send

### Download an object: # SZ filename ### download multiple objects: # SZ filename1 filename2 ### download all objects in the Dir directory, excluding folders in the Dir directory: # sz dir /*
  • Rz usage: receive back

### Simply type the RZ command # Rz

Enter RZ and press Enter. The file selection dialog box appears. Select the file to be uploaded. You can specify multiple files at a time,The path uploaded to the server is the directory where the RZ command is currently executed..


6. Set the default path

Securecrt:

Set the default directory for upload and download:

English version: Options-session options-x/y/zmodem.

Chinese version: Option-session option-x/y/zmodem.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/45/57/wKioL1PnilTTH9F9AAJuA3pVrtA097.jpg "style =" float: none; "Title =" 1 (1).png "alt =" wkiol1pniltth9f9aajua3pvrta097.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/45/56/wKiom1PniTzQ1nNWAAHEyqLtFF0295.jpg "style =" float: none; "Title =" 1 (2).png "alt =" wkiom1pnitzq1nnwaaheyqltff0295.jpg "/>


Xshell:

Set the default directory for upload and download:

File-> properties-> zmodem

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/45/57/wKioL1PnjQ-y0RR7AADUtYoANJ4284.jpg "style =" float: none; "Title =" 1 (1).png "alt =" wKioL1PnjQ-y0RR7AADUtYoANJ4284.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/45/56/wKiom1Pni_fS-2EKAAKi4aKC7m0124.jpg "style =" float: none; "Title =" 1 (2).png "alt =" wKiom1Pni_fS-2EKAAKi4aKC7m0124.jpg "/>


7. Operation demonstration (only xshell is demonstrated, and others are similar)

Rz command

After you enter the RZ command, a dialog box is displayed. Select the file to be transferred and click OK. The directory we receive is the directory where the RZ command is currently executed.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/45/57/wKioL1PnjlqB8eQUAAG4wewQgVU396.jpg "Title =" 1 (1).png "alt =" wkiol1pnjlqb8equaag4wewqgvu396.jpg "/>

Today, we found a simpler and more direct method to directly select the file and drag the file to xshell with the mouse.


SZ command

If I want to send a file, run the sz command directly, and then connect it to the file name. Similarly, after you press enter, a dialog box will pop up. Let's select the folder to be received.

[[email protected] ~]# sz nagios-4.0.7.tar.gz  nagios-plugins-2.0.3.tar.gz


This article is from the share your knowledge blog, please be sure to keep this source http://skypegnu1.blog.51cto.com/8991766/1538371

Related Article

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.