SCP,SFTP,FTP command usage and difference in Linux

Source: Internet
Author: User
Tags scp file

Scp

Help command: Man SCP

If you want to upload or want to download the directory, the best way is to use the tar compression, is the most sensible choice.
Downloading things from a remote host to the local computer

Copy File command

SCP User@host:/path/file/localpath//SCP user name @ip:/file path/local file path
If the copy directory is
Scp-r User@host:/dirpath/localpath//That is scp-r username @ip:/directory Path/local file path
Uploading files or directories from a local to a remote host

Upload files from local to remote host
SCP LocalFile User@host:/dirpath//SCP file path remote host user name @ip:/location file path
Upload directory from local to remote host
Scp-r Localdir User@host:/dirpath//That is scp-r local directory path remote host username @ip:/store file path

Sftp

For example, if the remote host IP is 202.206.64.33 or domain name WWW.9958.PW, the username is root, in the command line mode:

SFTP root@202.206.64.33
Or
SFTP ROOT@WWW.9958.PW
Enter the password by prompting for a carriage return. Enter prompt
Sftp>
Get means download in sftp; put means upload

Sftp> get remote host the path to the file to save the file to the local computer path
Sftp> the path of the put local file to save the file version to the remote host path
LS RM rmdir mkdir These commands are available. The same call to this machine is plus l, that is, Lls LRM.

To leave the SFTP, use Exit or quit, bye are available. For more information, man SFTP can be consulted.

Transfer files between Linux-linux:

$ ls
Aaamem oradiag_ttadmin Other test_scp.txt test_sftp.txt tt_packet ttadmin@10.xx.xx.xx
$ Who am I
Ttadmin PTS/3 Apr 15:35 (10.xxx.xxx.xxx)
$ sftp ttadmin@10.xx.xx.xx//sftp destination Server user name @ destination server address
Connecting to 10.xx.xx.xx ...
Password:
Sftp> put Test_sftp.txt
Uploading Test_sftp.txt To/export/home/ttadmin/test_sftp.txt
Sftp> bye
$ sftp 10.xx.xx.xx//At this point the connection destination server user name is the same as the native user
Connecting to 10.xx.xx.xx ...
Password:
sftp> pwd
Remote working directory:/export/home/ttadmin
Sftp> lpwd
Local working directory:/export/home/ttadmin

Sftp> ls//view contents of destination server directory
.
..
. Profile
Tt_packet
Sftp> LLS//View the contents of the local directory
Aaamem oradiag_ttadmin Other test_ftp.txt test_scp.txt test_sftp.txt tt_packet ttadmin@10.xx.xx.xx
Sftp>


Sftp> bye

$ SCP Test_scp.txtttadmin@10.xx.xx.xx:/export/home/ttadmin
Password:
Test_scp.txt 100% |********************************************************************************************* **********************************| 14 00:00
$ SCP Test_scp.txt ttadmin@10.xx.xx.xx:/export/home/ttadmin/test
Password:
Test_scp.txt 100% |********************************************************************************************* **********************************| 14 00:00
$

$ ftp
Ftp> Open 10.xx.xx.xx
Connected to 10.xx.xx.xx.
MEM1-NH FTP server ready.
Name (10.xx.xx.xx:ttadmin): Ttadmin
331 Password required for ttadmin.
Password:
230 User ttadmin logged in.
Remote system type is UNIX.
Using binary mode to transfer files.

Ftp> put Test_ftp.txt
PORT command successful.
Opening BINARY mode data connection for Test_ftp.txt.
Transfer complete.
Local:test_ftp.txt Remote:test_ftp.txt
9 Bytes Sent in 0.00057 seconds (15.46 kbytes/s)
Ftp> bye

Difference:

We do not talk about the difference between the mechanism and security of the three, but the difference between the use of the command. FTP and SFTP upload the destination server directory is fixed (user directory), SCP can make any directory (of course, must be the user's permission range directory). FTP and SFTP Use the difference is: sftp must be added after the parameters, FTP can not add parameters (enter the FTP command after the open ...) Connection to the destination server, you can also add parameters (only one parameter to the server address!). )。

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.