Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Ten SCP transfer command example     - Ubuntu 14.04 / 14.10 how to install FFmpeg 2.5.1 (Linux)

- How to download video youtube-dl in Linux (Linux)

- Java input and output common class Scanner (Programming)

- Create and modify Oracle temporary table space (Database)

- jQuery update the content and method of use 3.0 (Programming)

- Seven kinds of DDoS attack methods and techniques Defensive (Linux)

- Joseph Central Java implementation (Programming)

- Oracle Data Guard LOG_ARCHIVE_DEST_n optional attribute parameters (Database)

- Using LLVM Clang and Blocks under Linux (Programming)

- Java threads and thread pools (Programming)

- C # and JavaScript arrays to re-summary (Programming)

- Redis Linux system installation guide (Database)

- 64-bit Windows Server 2012 R2 install Oracle 10g Second Edition (Database)

- Ubuntu 14.04 Docker installation (Linux)

- MySQL 5.6 master-slave replication configuration (Database)

- CentOS 7 RHEL 7 to reset the root password (Linux)

- Linux disk and File System Concepts (Linux)

- Ganglia Python plug-in the process of writing notes (Linux)

- Shell Common Command Summary (Programming)

- Docker in the development and practice of IFTTT (Server)

 
         
  Ten SCP transfer command example
     
  Add Date : 2018-11-21      
         
         
         
  Linux system administrator should be very familiar with the CLI environment, because usually in the Linux server is not installed by the GUI. SSH may be the Linux system administrators to remotely manage the security of the most popular server protocol. A built-in command called SCP SSH command, used to transfer files between servers.

The following command can be interpreted as follows: the "username account" "copy of the source file name" to "destination folder" destination host "on the" inside.

The basic syntax of the command SCP

scp source_file_name username @ destination_host: destination_folder
SCP command has many parameters that can be used here refers to the parameters used each time.

With the -v parameter to provide detailed information on SCP process

SCP basic command with no arguments copies files in the background, unless the operation is completed or an error occurs, the user interface is otherwise not see any prompt information. You can print out debugging information on the screen, which can help you debug connection, authentication, and configuration problems with "-v" argument.

pungki @ mint ~ / Documents $ scp -v Label.pdf mrarianto@202.x.x.x :.
Output section

Executing: program / usr / bin / ssh host 202.x.x.x, user mrarianto, command scp -v -t.
OpenSSH_6.0p1Debian-3, OpenSSL1.0.1c10May2012
debug1: Reading configuration data / etc / ssh / ssh_config
debug1: / etc / ssh / ssh_config line 19: Applying options for *
debug1: Connecting to 202.x.x.x [202.x.x.x] port 22.
debug1: Connection established.
debug1: Host'202.x.x.x'is known and matches the RSA host key.
debug1: Found key in / home / pungki / .ssh / known_hosts: 1
debug1: ssh_rsa_verify: signature correct
debug1: Next authentication method: password
mrarianto@202.x.x.x's password:
debug1: Authentication succeeded (password).
Authenticated to 202.x.x.x ([202.x.x.x]: 22).
Sending file modes: C0770 3760348 Label.pdf
Sink: C0770 3760348 Label.pdf
Label.pdf 100% 3672KB 136.0KB / s 00:27
Transferred: sent 3766304, received 3000 bytes, in 65.2 seconds
Bytes per second: sent 57766.4, received 46.0
debug1: Exit status 0
Being modification times, access times, and modes from the source file

"-p" Parameter will help to put the expected time and connection speed will be displayed on the screen.

pungki @ mint ~ / Documents $ scp -p Label.pdf mrarianto@202.x.x.x :.
Output section

mrarianto@202.x.x.x's password:
Label.pdf 100% 3672KB 126.6KB / s 00:29
With the -C parameter to allow faster file transfers

There is an argument to make transferring files faster, is "-C" parameter, its role is to keep the compressed file transfer. It is unique in that compression is carried out in the network transmission, when the files to the target server, it changes back to its original size before compression.

Take a look at these commands, we use a single file for the example of a 93 Mb.

pungki @ mint ~ / Documents $ scp -pv messages.log mrarianto@202.x.x.x :.
Output section

Executing: program / usr / bin / ssh host 202.x.x.x, user mrarianto, command scp -v -p -t.
OpenSSH_6.0p1Debian-3, OpenSSL1.0.1c10May2012
debug1: Reading configuration data / etc / ssh / ssh_config
debug1: / etc / ssh / ssh_config line 19: Applying options for *
debug1: Connecting to 202.x.x.x [202.x.x.x] port 22.
debug1: Connection established.
debug1: identity file /home/pungki/.ssh/id_rsa type -1
debug1: Found key in / home / pungki / .ssh / known_hosts: 1
debug1: ssh_rsa_verify: signature correct
debug1: Tryingprivate key: /home/pungki/.ssh/id_rsa
debug1: Next authentication method: password
mrarianto@202.x.x.x's password:
debug1: Authentication succeeded (password).
Authenticated to 202.x.x.x ([202.x.x.x]: 22).
debug1: Sending command: scp -v -p -t.
File mtime 1323853868 atime 1380425711
Sending file timestamps: T1323853868 0 1380425711 0
messages.log 100% 93MB 58.6KB / s 27:05
Transferred: sent 97614832, received 25976 bytes, in 1661.3 seconds
Bytes per second: sent 58758.4, received 15.6
debug1: Exit status 0
Not "-C" parameter to copy files, with the result 1661.3 seconds, you can compare the results with the next parameter after "-C".

pungki @ mint ~ / Documents $ scp -Cpv messages.log mrarianto@202.x.x.x :.
Output section

Executing: program / usr / bin / ssh host 202.x.x.x, user mrarianto, command scp -v -p -t.
OpenSSH_6.0p1Debian-3, OpenSSL1.0.1c10May2012
debug1: Reading configuration data / etc / ssh / ssh_config
debug1: / etc / ssh / ssh_config line 19: Applying options for *
debug1: Connecting to 202.x.x.x [202.x.x.x] port 22.
debug1: Connection established.
debug1: identity file /home/pungki/.ssh/id_rsa type -1
debug1: Host'202.x.x.x'is known and matches the RSA host key.
debug1: Found key in / home / pungki / .ssh / known_hosts: 1
debug1: ssh_rsa_verify: signature correct
debug1: Next authentication method: publickey
debug1: Tryingprivate key: /home/pungki/.ssh/id_rsa
debug1: Next authentication method: password
mrarianto@202.x.x.x's password:
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (password).
Authenticated to 202.x.x.x ([202.x.x.x]: 22).
debug1: channel 0: new [client-session]
debug1: Sending command: scp -v -p -t.
File mtime 1323853868 atime 1380428748
Sending file timestamps: T1323853868 0 1380428748 0
Sink: T1323853868 0 1380428748 0
Sending file modes: C0600 97517300 messages.log
messages.log 100% 93MB 602.7KB / s 02:38
Transferred: sent 8905840, received 15768 bytes, in 162.5 seconds
Bytes per second: sent 54813.9, received 97.0
debug1: Exit status 0
debug1: compress outgoing: raw data 97571111, compressed 8806191, factor 0.09
debug1: compress incoming: raw data 7885, compressed 3821, factor 0.48
See, compressed files after transfer process in 162.5 seconds to complete, the speed is not "-C" parameter 10 times. If you want to copy a lot of documents over the network, then the "-C" argument can save you a lot of time off.

One thing we need to note that this compression method is not applicable to all files. When the source file has been compressed, and that there is no way to re-compress a lot. Such as those who, like .zip, .rar, pictures and .iso files with "-C" argument is pointless.

Select other encryption algorithm to encrypt files

SCP default is "AES-128" encryption algorithm to encrypt the transmission. If you want to use other encryption algorithm to encrypt the transmission, you can use the "-c" parameter. Let's see.

pungki @ mint ~ / Documents $ scp -c 3desLabel.pdf mrarianto@202.x.x.x :.
 
mrarianto@202.x.x.x's password:
Label.pdf 100% 3672KB 282.5KB / s 00:13
The above command is used to tell SCP 3des algorithm to encrypt files. Note that this parameter is "-c" (lowercase) instead of "-C" (uppercase).

Limit bandwidth usage

There is also a very useful parameter is "-l" parameter, which limits the use of bandwidth. If you copy a lot of files in order to perform an automated script away and do not want the bandwidth is exhausted SCP process, then this parameter will be very useful.

pungki @ mint ~ / Documents $ scp -l 400Label.pdf mrarianto@202.x.x.x :.
 
mrarianto@202.x.x.x's password:
Label.pdf 100% 3672KB 50.3KB / s 01:13
In the "-l" parameter value behind the 400 to the SCP process means that we limit the bandwidth of 50 KB / sec. One thing to keep in mind that the bandwidth is kilobits / second (kbps) represented, and 8 bits equals one byte.

Because SCP is kilobytes / second (KB / s) calculated, so if you want to limit the maximum bandwidth SCP only 50 KB / s, you will need to set up a 50 x 8 = 400.

Designated port

SCP is typically 22 as the default port. However, for security purposes SSH listening port changed to other ports. For example, we want to use port 2249, in which case we must specify the port. Command is shown below.

pungki @ mint ~ / Documents $ scp -P 2249Label.pdf mrarianto@202.x.x.x :.
 
mrarianto@202.x.x.x's password:
Label.pdf 100% 3672KB 262.3KB / s 00:14
Confirm what is written in capital letters "P" instead of "p", because "p" has been used to modify the retention time and the mode of the source file (LCTT translation: ssh command and different).

Recursively copy files and folders

Sometimes we need to copy the folder and all files inside / subfolders, if we can use a single command to solve the problem so much the better. SCP with the "-r" parameter can do.

pungki @ mint ~ / Documents $ scp -r documents mrarianto@202.x.x.x :.
 
mrarianto@202.x.x.x's password:
Label.pdf 100% 3672KB 282.5KB / s 00:13
scp.txt 100% 10KB 9.8KB / s 00:00
After the copy is complete, you will find the target server in a file called "documents" folder, which is to copy all the files. "Documents" file is automatically created folder.

Disabling progress bar and a warning / diagnostic information

If you do not want to see a progress bar and a warning / diagnostic information from the SCP, you can silence them with "-q" parameter, for example as follows.

pungki @ mint ~ / Documents $ scp -q Label.pdf mrarianto@202.x.x.x :.
 
mrarianto@202.x.x.x's password:
pungki @ mint ~ / Documents $
As you can see, after you enter the password, there is no news about the progress of SCP feedback. After the schedule is completed, you can not see any hints.

Use SCP to copy files through a proxy

Proxy servers are often used in office environments, SCP nature is not configured the proxy aspect. When your environment is using a proxy, then you have to "tell" the SCP associated with the proxy.

Scenario is as follows: Agent address 10.0.96.6, the port is 8080. The agent also implements user authentication function. First, you need to create a "~ / .ssh / config" file, followed by the following command into the input file.

ProxyCommand / usr / bin / corkscrew 10.0.96.68080% h% p ~ / .ssh / proxyauth
Then you need to create an equally include "~ / .ssh / proxyauth" file the following command.

myusername: mypassword
Then you can use as usual the SCP.

Please note that the corkscrew may not have installed on your system. In my Linux Mint, I need to first use the standard Linux Mint installer to install it.

$ Apt-get install corkscrew
For some other install yum-based systems, the user can use the following command to install the corkscrew.

# Yum install corkscrew
Another point is that because the "~ / .ssh / proxyauth" file contains your "username" and "password" in clear text format, so you can make sure that the file to view.

Choose a different file ssh_config

For mobile users often between the corporate network and the public switched network, the setting has been changed SCP is obviously very painful. If we can put a different saved configuration file ssh_config to match our needs would be quite good.

The following is a simple scene

Agents are being used in the corporate network, but not the public network and you regularly switch networks when used.

pungki @ mint ~ / Documents $ scp -F / home / pungki / proxy_ssh_config Label.pdf
 
mrarianto@202.x.x.x :.
mrarianto@202.x.x.x's password:
Label.pdf 100% 3672KB 282.5KB / s 00:13
By default, each user will "ssh_config" file in the "~ / .ssh / config" path. Create a specific "ssh_config" file with a compatible agent, allowing easier easier when you switch networks.

When you are in a company network, you can use the "-F" parameter when you are in a public network, you can ignore the "-F" parameter.

Is about more than the entire contents of the SCP, you can view the SCP man page for more information, please feel free to leave your comments and suggestions.
     
         
         
         
  More:      
 
- CentOS 6.5 installation using a data recovery software extundelete (Linux)
- To install Ganglia configuration of experience under CentOS 5.5 (Linux)
- Android Application Development: an argument between Activity (Programming)
- Ubuntu UFW firewall settings Introduction (Linux)
- Using BBED repair ORA-01190 error (Database)
- To install file manager Nautilus 3.12.2 under ubuntu (Linux)
- Java open source monitoring platform Zorka basic use (Linux)
- Linux Network Programming - libnet Guide (Programming)
- OpenVPN offsite interconnecting room availability and load balancing solution (Server)
- Ubuntu 14.04 installation configuration GNOME Classic interface (Linux)
- The next key to install Linux bash script PowerShell (Linux)
- Let your PHP 7 faster the Hugepage (Linux)
- Source code to compile and install MySQL 5.7.9 (Database)
- Ubuntu server 8.04 Firewall Guide (Linux)
- Installation and Configuration rsync server under CentOS 6.3 (Server)
- Django Signals from practice to source code analysis (Programming)
- Binary search is really easy as you think you do (Programming)
- Linux basic articles of the boot process (Linux)
- How Datadog monitor Nginx (Server)
- Linux netstat command to get started (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.