Use SecureCRT's sftp to transfer files between Windows and Linux

Source: Internet
Author: User
Tags control characters symlink smokeping

Background: There is a host that installs the Windows7, installs the VirtualBox in it, and then installs the Ubuntu virtual machine. Install SECURECRT on Windows7 to SSH to the Ubuntu virtual machine. Generally download software on windows and then upload it to Ubuntu virtual machine via vsftp. But this is very troublesome, now consider using the SFTP protocol to transfer directly. Scenario: Use SECURECRT software ssh to connect to an Ubuntu virtual machine. Then open the SFTP session above the SECURECRT, and you can press ALT + PThe key combinations are as follows: After the SFTP command enters the sftp command window, the SFTP command can be used to perform the file transfer operation. Here is a brief description of what the SFTP command means.
sftp> helpavailable commands:ascii Set transfer mode to Asciibinary Se T transfer mode to BINARYCD path change remote directory to ' path ' LCD path Ch                                 Ange local directory to ' path ' detail Remote-path Display system Information about remote                                 File or Folderldetail Local-path Display System Information about local File or folderchgrp group path Change group of file ' path ' to ' group ' chmod mode path Cha                           Nge Permissions of file ' path ' to ' mode ' chown owner path Change owner of the file ' path ' to ' owner ' exit Quit sftphelp Display This help textinclude filename Include com                         Mands from ' filename ' Alternate: < Filenameget [-r][-a |-b] remote-path Download file         -R Downloads Directory recursively force ASCII (-a) or binary (-B) Modeln [-S] Ex Istingpath linkpath hardlink/symlink remote filels [options] [path] Display remote directory listinglls [opt                    Ions] [path] Display local directory listingmkdir path Create remote Directorylmkdir path Create local DIRECTORYMV oldpath newpath move remote FILELMV oldpath newpath move                                  Local FileOpen [[email protected]]host[:p ORT] Connect to remote hostput [-r][-a |-b] local-path Upload file -R uploads Directory recursively force ASCII (-a) or Bina Ry (-B) modepwd Display remote working directorylpwd Print local work ing directoryquit Quit sftprename oldname newname Rename remote Filelrename oldname newn Ame Rename LocalFilermdir path Remove remote directorylrmdir path remove local directoryrm path Delete remote FILELRM path Delete local filesu username Subst                                  Itutes The current user This is only supported with Vshell for               Windows 3.5 or Later.type [Transfer-mode] Display or set file transfer Modeview Remote-path Download and open fileversion Display protocol version

The translation is:

sftp--Help available command: CD path change remote directory to "path" LCD path change local directory to "path" CHGRP Group path Change the file "path" group to "group" chmod mode path changes the file "path" permission to "mode" chown owner path will file "Pat                   H "Master Change to" owner "exit exit SFTP Help show this helper text get remote path  Download File ln existingpath linkpath symbolic link remote file ls [options] [path] Display remote directory list LLS [options] [path] Show local directory list mkdir         Path creation remote Directory lmkdir path Create local directory MV OldPath newpath Mobile remote File Open [user @] host [: Port] Connect to a remote host put local path upload file pwd display remote working directory LPWD print This                         To work directory quit exit sftp rmdir path Remove remote directory lrmdir path remove local directory RM path                        Delete remote file LRM Path Delete local file symlink existingpath linkpath Symbolic Link Remote file version  Show Protocol version

The main thing we're using is a six-command.

CD path                        change remote directory to "path" LCD path                       change local directory to "path" ls [options] [path]               display remote directory list LLS [options] [path]              show local directory list put local path                   upload file get remote Path                   

Here is a detailed description of the remote directory and the local directory .

Remote directory: LS Check the directory above the Ubuntu virtual machine

Local directory: LLS look at the directory above the Windows physical machine.

Instance:

Let's say I need to implement E:\sftp\test1.txt and Ubuntu under/home/enadmin/test2.txt in Windows, and you can do it:

Put operation: Windows->linux

View Directory Permissions

[Email protected]:/home# lltotal 20drwxr-xr-x  5 root    root    4096 Apr 15:21./drwxr-xr-x Root    root
   4096 Jan  3 14:14.. /drwxr-xr-x  9 enadmin enadmin 4096 Apr 15:22 enadmin/drwxr-xr-x  2 root    root    4096 Apr 15:21 sftp/--can See SFTP permissions is root drwxr-xr-x  2 root    4096 Apr 14:57 test/[email protected]:/home# chown-r Enadmin.enadmin sftp/[email protected]:/home# lltotal 20drwxr-xr-x  5 root    root    4096 APR 18 15:21. Drwxr-xr-x root    root    4096 Jan  3 14:14.. /drwxr-xr-x  9 enadmin enadmin 4096 Apr 15:22 enadmin/drwxr-xr-x  2 enadmin enadmin 4096 APR 15:21 sftp/--modified Later permissions become enadmin drwxr-xr-x  2 root    root    4096 APR 14:57 test/

Copy files

Sftp> put test*--initially wanted to put files from the Windows system to the Ubuntu system, found that failed, prompting to deny access uploading test1.txt to/home/test1.txtput:failed to Upload E:/sftp/test1.txt. Access denied. Uploading test2.txt to/home/test2.txtput:failed to upload e:/sftp/test2.txt. Access denied. Uploading test3.txt to/home/test3.txtput:failed to upload e:/sftp/test3.txt. Access denied. sftp> pwd--View current directory is the/home directory, permissions are root/homesftp> cd/home/enadmin/--i switch to enadmin directory sftp> lsgraphs.pm MSM                TP Ntpsent smokeping.tar.gz smokepingrtt.tar.gzsmokepingrtt2.tar.gz Target Wqywqy-zenhei-0.8.38-1.debsftp> llstest1.txt test2.txt test3.txtsftp> put test*-try again     Put the files under Windows into the/homg/enadmin directory, this success uploading test1.txt to/home/enadmin/test1.txt 100% 4 bytes 4 bytes/s 00:00:00 E:/sftp/test1.txt:4 bytes transferred in 0 seconds (4 bytes/s) uploading Test2.txt to/home/enadmin/test2.txt 100% 4 Bytes 4 bytes/s 00:00:00 e:/sftp/test2.txt:4 bytes Transferred IN 0 seconds (4 bytes/s) uploading test3.txt to/home/enadmin/test3.txt 100% 5 bytes 5 bytes/s 00:00:00 e:/sftp/te St3.txt:5 bytes transferred in 0 seconds (5 bytes/s) sftp> cd/home/sftp/--After modifying the SFTP directory permissions, switch to the SFTP directory again sftp> LSSFTP&G T Llstest1.txt test2.txt test3.txtsftp> put test*-this time put succeeds. So with permission related uploading test1.txt to/home/sftp/test1.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test1.txt:4 bytes TR Ansferred in 0 seconds (4 bytes/s) uploading test2.txt to/home/sftp/test2.txt 100% 4 bytes 4 bytes/s 00:00:00 e:      /sftp/test2.txt:4 bytes transferred in 0 seconds (4 bytes/s) uploading test3.txt to/home/sftp/test3.txt 100% 5 bytes 5 bytes/s 00:00:00 e:/sftp/test3.txt:5 bytes transferred in 0 seconds (5 bytes/s)

Note: There is a need to pay attention to the issue of permissions. Join me is using enadmin account initial connection Ubuntu, then I put the file can only put folder permissions is Enadmin directory, cannot put folder permissions is root directory. If you want to put the folder permissions in the root directory, then initially use the root account to connect to Ubunut, and then create an SFTP session, so you can.

Get Operation: Linux->windows

Get operation does not have permission set

sftp> pwd/home/enadminsftp> lpwde:/documentssftp> LCD e:/sftp--Switch directory sftp>             llsrc.local test1.txt test2.txttest3.txtsftp> lsgraphs.pm             msmtp                 ntpsent                  smokeping.tar.gz      smokepingrtt.tar.gzsmokepingrtt2.tar.gz  Target                test1.txttest2.txt             test3.txt             Wqywqy-zenhei-0.8.38-1.debsftp> get graphs.pm--download file to windowsdownloading graphs.pm from/home/enadmin/graphs.pm  100% 13KB     13kb/s 00:00:00     /home/enadmin/graphs.pm:13503 bytes transferred in 0 seconds (kb/s) sftp > Lls--View windows directory graphs.pm             rc.local              test1.txttest2.txt             

Method of transferring files to Linux under window.

First install the SECURECRT in the window, and then set up a connection to Linux in the fast connection, of course, you have to know the IP of your system, in the terminal type Ifconfig can be viewed.

Then connect and log in to the Linux terminal

To transfer files from Linux to window, this requires a CD to the directory of the files you want to pass, and then use the command: SZ file name to upload. Put the file under Securesrt/download.

To transfer files from window to Linux, enter RZ in the terminal and a dialog box will let you choose the file transfer.

In general, most of the Linux server through the SSH client for remote login and management, using SSH login to the Linux host, how to quickly and the local machine for file interaction, that is, upload and download files to the server and local;

The two commands associated with SSH can be easily manipulated:

SZ: Send the selected file (send) to the local machine

RZ: Run this command will pop up a file Selection window, from the local select File upload to the server (receive)

Rz,sz is the command-line tool that Linux/unix Zmodem file transfer with Windows

The Windows side needs to support Zmodem TELNET/SSH clients (such as SECURECRT)

Run the command RZ, that is, to receive the file, SecureCRT will pop up the file selection dialog box, select the file and close the dialog box, the file will be uploaded to the current directory

Note: Using RZ alone will have two problems: Upload interrupt, upload file changes (MD5 different), the solution is to upload is rz-be, and remove the popup dialog box "Upload files as ASCII" before the check.

-b binary uploads the download in binary mode, does not interpret the character as ASCII

-E force escape all control characters, such as Ctrl+x,del, etc.

Run the command sz file1 file2 is to send files to Windows (the saved directory can be configured) more convenient than the FTP command, and the server does not have to open the FTP service

Ps:linux on the Rz/sz these two gadgets installed lrzsz-x.x.xx.rpm can be.

Of course, you can also set up the directory:

Set the default directory for uploads and downloads

Options–>session options–>file transfer can be set to upload and download the directory

The rest of you just log in to the Linux terminal with SECURECRT:

Send file to client: SZ filename

Zmodem receive can start on its own.

Upload files from client to Linux server:

As long as the server execution: RZ

Then select the file to send in SecureCRT, protocol Zmodem

Attached: Yum reverse the installation package usage according to the command name

For example, the installation package name of the RZ command

Yum  whatprovides */rz

Use SecureCRT's sftp to transfer files between Windows and Linux

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.