Using scp to copy files remotely in Linux

Source: Internet
Author: User
In Linux, copy files remotely using scp-Linux Enterprise Application-Linux server application information. The following is a detailed description. SSH provides commands and shells to log on to the remote server. By default, it does not allow you to copy files, but still provides a "scp" command.
Suppose you want to copy a file named "wuyang" in the current directory of the Local Computer to your home directory on the remote server 192.168.0.2. In addition, the name of your account on the remote server is "root ". You can use this command:
Scp wuyang root@192.168.0.2

Copy the file back and use this command:
Scp root@192.168.0.2: wuyang

Scp command
The scp command is the most convenient and useful command in SSH.
To transfer files, simply use the scp command to completely solve the problem. You can
Run as root # scp servername:/home/ftp/pub/file1.
Files/home/ftp/pub/file1 on a server are directly uploaded to the current directory of the machine,
Of course, you can also use # scp/tmp/file2 servername:/boot to put files on the local machine
/Tmp/file2 is sent to the/boot directory of another machine. And the entire transfer process is still
Encrypted by SSH.

Use the man command to explain:

Man Scp | more
Reformatting rcp (1), please wait...
SCP (1) BSD General Commands Manual SCP (1)

NAME
Scp-secure copy (remote file copy program)

SYNOPSIS
Scp [-1246 BCpqrv] [-c cipher] [-F ssh_config] [-I identity_file]
[-L limit] [-o ssh_option] [-P port] [-S program]
[[User @] host1:] file1 [...] [[user @] host2:] file2

DESCRIPTION
Scp copies files between hosts on a network. It uses ssh (1) for data
Transfer, and uses the same authentication and provides the same security
As ssh (1). Unlike rcp (1), scp will ask for passwords or passphrases if
They are needed for authentication.

Any file name may contain in a host and user specification to indicate that
The file is to be copied to/from that host. Copies between two remote
Hosts are permitted.

The options are as follows:

-1 Forces scp to use protocol 1.
-2 Forces scp to use protocol 2.

-4 Forces scp to use IPv4 addresses only.

-6 Forces scp to use IPv6 addresses only.

-B Selects batch mode (prevents asking for passwords or
Passphrases ).

-C Compression enable. Passes the-C flag to ssh (1) to enable com-
Expression.

-C cipher
Selects the cipher to use for encrypting the data transfer. This
Option is directly passed to ssh (1 ).

-F ssh_config
Specifies an alternative per-user configuration file for ssh.
This option is directly passed to ssh (1 ).

-I identity_file
Selects the file from which the identity (private key) for RSAauthentication is read. This option is directly passed
Ssh (1 ).

-L limit
Limits the used bandwidth, specified in Kbit/s.

-O ssh_option
Can be used to pass options to ssh in the format used in
Ssh_config (5). This is useful for specifying options for which
There is no separate scp command-line flag. For full details
The options listed below, and their possible values, see
Ssh_config (5 ).

AddressFamily
BatchMode
BindAddress
ChallengeResponseAuthentication
CheckHostIP
Cipher
Ciphers
Compression
CompressionLevel
ConnectionAttempts
ConnectionTimeout
GlobalKnownHostsFile
GSSAPIAuthentication
GSSAPIDelegateCredentials
Host
HostbasedAuthentication
HostKeyAlgorithms
HostKeyAlias
HostName
IdentityFile
IdentitiesOnly
LogLevel
MACs
NoHostAuthenticationForLocalhost
NumberOfPasswordPrompts
PasswordAuthentication
Port
PreferredAuthentications
Protocol
ProxyCommand
PubkeyAuthentication
RhostsRSAAuthentication
RSAAuthentication
ServerAliveInterval
ServerAliveCountMax
SmartcardDevice
StrictHostKeyChecking
TCPKeepAlive
UsePrivilegedPort
User
UserKnownHostsFile
VerifyHostKeyDNS

-P port
Specifies the port to connect to on the remote host. Note that
This option is written with a capital 'P', because-P is already
Reserved for preserving the times and modes of the file in
Rcp (1 ).

-P Preserves modification times, access times, and modes from
Original file.

-Q Disables the progress meter.

-R Recursively copy entire directories.
-S program
Name of program to use for the encrypted connection. The program
Must understand ssh (1) options.

-V Verbose mode. Causes scp and ssh (1) to print debugging messages
About their progress. This is helpful in debugging connection,
Authentication, and configuration problems.

DIAGNOSTICS
Scp exits with 0 on success or> 0 if an error occurred.

SEE ALSO
Rcp (1), sftp (1), ssh (1), ssh-add (1), ssh-agent (1), ssh-keygen (1 ),
Ssh_config (5), sshd (8)

HISTORY
Scp is based on the rcp (1) program in BSD source code from the Regents
The University of California.

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.