By rz SecureCRT's, sz and sftp for file upload and download for Linux

SecureCRT has the following file transfer protocols:
① ASCII: the fastest transfer protocol, but can only send text files;
② Xmodem: old transfer protocol, slower but uses a CRC error detection method, the accuracy rate transmission can be % up to 99.6;
③ Ymodem: Xmodem is a modified version, the use of segment 1024 transmission, faster than Xmodem;
④ Zmodem: Zmodem transmission stream using the formula (streaming), faster transmission, but also has an automatic change the size of the segments and HTTP, fast error detection and other functions.

Zmodem is the most popular file transfer protocol, the following rz / sz command is to transfer files via Zmodem mode.

1 by rz / sz commands upload / download

1.1 Software installation lrzsz

[root@host-10-0-20-50 ~]# sudo yum install -y lrzsz

If the server can not connect to external networks, reference may CentOS 6.5 dstat resource statistics are used to install the tool settings.

1.2 rz - upload files

rz r is the abbreviation received (reception), meaning the server receives a file (received by client), that is, upload local files to the server.

Type rz command, and then press Enter to bring up the file selection dialog box, select the file you want to upload, select multiple files.

Click OK to upload a file, the file path for the receive path of the currently executing rz command .

Process is as follows:

[root@host-10-0-20-50 ~]# rz
rz waiting to receive.
Starting zmodem transfer.  Press Ctrl+C to cancel.

SecureCRT upload files

Note: Upload file, if the file has the same name directory Linux server receives the file upload process will skip information is as follows:

[root@host-10-0-20-50 elk]# rz
rz waiting to receive.
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring elasticsearch-5.6.10.tar.gz...
elasticsearch-5.6.10.tar.gz was skipped

SecureCRT skip files with the same name

Extended: Use rz have two questions: Upload interrupted upload files that have changed (different md5) - has not been verified, please doubtful.

Solution: When you upload with rz -be, and uncheck the dialog box "Upload files as ASCII" before the check box.

-b: upload and download a binary way, do not interpret the characters as ASCII.
-e: Forced escape all control characters, such as Ctrl + x, DEL and so on.

1.3 sz - download file

sz of s is an abbreviation send (send), meaning the server to send the file to the client (send to client), that is downloaded to the local file server.

Type sz download_files command, and then press Enter, you can download the file to the server configuration directory SecureCRT:

Process is as follows:

[root@host-10-0-20-50 ~]# cd /data/elk
[root@host-10-0-20-50 ~]# sz elasticsearch-5.6.10.tar.gz

SecureCRT Download file

(1) sz other usage:

sz filename                 # 下载一个文件
sz filename1 filename2      # 下载多个文件
sz dir/*                    # 下载dir目录下的所有文件, 不包含dir下的文件夹

(2) 修改SecureCRT默认的上传/下载目录:

选择菜单栏的[Options(选项)] --> [Session Options(会话选项)] --> [X/Y/Zmodem], 然后修改Upload/Download路径即可.

2 通过sftp上传/下载文件

为了数据和服务的安全, 很多生产环境中的Linux服务器不能使用外网环境. 在只有SSH连接的情况下, 传输文件变得很不方便.

如果Linux服务器未安装用于上传和下载的lrzsz软件, 又不能现场安装, 此时可考虑使用sftp完成相关操作.

2.1 关于SFTP的简介

SFTP是Secure File Transfer Protocol(安全文件传输协议)的缩写, 可以为传输文件提供一种安全的网络的加密方法.

不需要单独安装或配置sftp —— 支持SSH连接的服务器, 也就默认开启了SFTP.

SFTP是SSH的一部分: 在SSH软件包中, 已经包含了SFTP安全文件信息传输子系统.

SFTP本身没有单独的守护进程, 它必须使用sshd守护进程 (端口号默认是22) 来完成相应的连接和答复操作.

所以从某种意义上来说, SFTP并不像一个服务器程序, 而更像是一个客户端程序.

2.2 SFTP与FTP的区别

① FTP是一种方便数据共享的文件传输协议, 包括一个FTP服务器和多个FTP客户端. FTP客户端通过FTP协议从服务器上下载资源.

② SFTP协议是在FTP的基础上, 对数据采取了加密/解密技术, 使数据传输更安全.

SFTP的传输效率比FTP的低很多.

2.3 使用SFTP之前的工作

Windows系统下, 可以使用Core FTP、FileZilla、WinSCP、Xftp等软件来连接SFTP进行上传/下载文件、建立/删除目录等操作.

这里主要探讨Linux系统下的操作.

(1) 软件环境:

可以使用任意终端工具, 比如MacOS下的Terminal, 或iTerm(此处演示使用), 或SecureCRT.

(2) sftp建立连接:

在终端中进行操作, 若打开SecureCRT的sftp: 菜单栏的[File] --> [Connect SFTP Session]即可.

# 在默认的SSH端口(22)下连接: 
# sftp username@remote_ip(or remote host name), 连接root用户, 则可省略"root@".  
sftp [email protected]

# 在其他端口下的连接
sftp -o port=1000 username@remote_ip

如果出现验证, 填入正确的密码后即可实现远程连接. 连接成功后终端信息如图:

sftp login

2.4 sftp - 上传文件

sftp与ftp有着几乎相同的语法和功能:

ls, rm, cd, mkdir, pwd 等指令是对当前连接的远程端服务器的操作;

lls, lrm, lcd, lmkdir, lpwd 等指令是对本地端服务器的操作 —— 在上述指令前加l(local)即可.

上传操作示例:

# 默认连接的都是root目录, 查看本地和远端/root路径下的文件: 
sftp> lls               # 本地
anaconda-ks.cfg  install.log  install.log.syslog  porc  remote.sh  test.sh
sftp> ls                # 远端
anaconda-ks.cfg  install.log  install.log.syslog  myid  remote.sh  test.sh

# 将本地的remote.sh文件上传至远端服务器的/home路径下: 

sftp> put remote.sh /home       # 指定远端接收路径为/home
Uploading remote.sh to /home/remote.sh
remote.sh                                   100%  538     0.5KB/s   00:00
sftp> ls /home                  # 查看远端/home路径下的文件
/home/remote.sh

2.5 sftp - 下载文件

下载操作示例:

# The file myid distal end / root downloaded to the local path / home Path: 
SFTP> GET / root / myid / home specified remote file # + local reception path 
Fetching / root / myid to / home / myid 
SFTP> LLS / home # view the files in the local / home path 
myid

If you upload / download the folder, the put / get command with the -r parameter.

Screenshot above operation is as follows:

sftp upload / download chart

Quit sftp:

In the terminal input quit or exit, and then the transport, can exit sftp connection.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160261.htm