Sftp and scp in linux

Source: Internet
Author: User
Tags ftp connection
ScpScp2 is used to securely copy files from the network. It uses ssh2 for data transmission: It uses the validation method and provides the same security as ssh2. This may be the easiest way to copy files from a remote machine. Let's assume you want to use you...

 

Scp

Scp2 is used to securely copy files from the network. It uses ssh2 for data transmission: It uses the validation method and provides the same security as ssh2.

This may be the easiest way to copy files from a remote machine. Let's assume that you want to use your account mmyname to copy the filename in the local_dir Directory

File to the remote_dir directory on host1. With scp, you can enter:

Scp local_dir/filename myname @ host1: remote_dir

In this way, the file filename is copied to the same name. Wildcard characters can be used (read sshregex manual ). Command line:

Scp local_dir/* myname @ host1: remote_dir

Run the remote_dir command to copy all files from the local_dir directory to the host1 directory on the host:

Scp myname @ host1: remote_dir/filename.

Copy the filename file from the remote_dir directory of host1 to the local directory.

Scp supports many options and allows file copying between two remote systems:

Scp myname @ host1: remote_dir/filename myname @ host2: another_dir

For more information, see the manual.

Obviously, when using scp, you must know the exact Directory of the remote machine, so sftp is often used as the first choice.

 

Sftp

Sftp uses ssh2 for data connections, so file transmission is as secure as possible. Two main reasons for using sftp to replace ftp are:

1. Password is never transmitted in plain text to prevent sniffer attacks.

2. data is encrypted during transmission. it is very difficult to use spying and modify connections.

Using sftp2 is very simple. Let's assume that you have used your account: myname is connected to host host1 through sftp.

 

You can run the following command:

Sftp myname @ host1

Some options can be specified in the command line (for details, see sftp manul)

When sftp2 is ready to accept the connection, it displays a status prompt sftp>. The sftp manual contains a complete list of commands that can be used by users:

· Quit:

Exit from this application.

· Cd directory:

Change the current remote working directory.

· LCD directory:

Change the current local working directory.

· Ls [-R] [-l] [file...]:

List the file names on the remote server. If it is a directory, the contents of the directory are listed. If-R is specified in the command line, the directory tree is displayed recursively. (By default, subdirectories are not accessed ). When-l is specified in the command line, the file and directory permissions, owner, size, and modification time are listed.

If no parameter is specified, the contents of. (current directory) are listed. In general, options-R and-l are incompatible.

· Lls [-R] [-l] [file...]:

Like ls, but it is for local files.

· Get [file...]:

Transfers the specified file from the remote end to the local end. Directory content is recursively copied.

· Put [file...]:

Transfers the specified file from the local end to the remote end. Directory content is recursively copied.

· Mkdir dir (rmdir dir ):

Try to create or delete the directory specified in the parameter.

Wildcards are supported for ls, lls, get, and put. The format is described in the sshregex manual. Since sftp's use of encryption technology, there has been an obstacle: the connection speed is slow (2-3 times in my experience), but this can only be put aside for very good security. In one test, Sniffer on our Lan can catch four passwords on the ftp connection in one hour. Sftp can transfer files from the network and remove these security issues.

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.