Linux Utility - Scp (secure copy, remote file copy) command

Bash Liste Des Attaques Ovh


File Transfer - SCP (Secure Copy) in Linux.


    [-c cipher] 
    [-F ssh_config] 
    [-i identity_file] 
    [-l limit] 
    [-o ssh_option] 
    [-P port] 
    [-S program]
    [[user@]host1:]SourceFile1 [...] [[user@]host2:]TargetFile2

How to

Transfer files from one Linux host to an other

A directory

Example to copy recursively the local directory to a remote with sshpass to pass the password

sshpass -f "/my/file/witth/pwd" \
   scp -pr . TargetUser@TargetHostname:/Target/Directory


  • -p Preserves modification times, access times, and modes from the original file.
  • r Recursively copy entire directories.

You may be able to pass the password with the PWD environment variable.

scp -pr . TargetUser@TargetHostname:$PWD

One file

sshpass -p "mypassword"  \
scp -p myFile myDestinationUser@MyDestinationHost:/myPath/myFile


  • -p Preserves modification times, access times, and modes from the original file.
The authenticity of host 'MyDestinationHost(' can't be established.
RSA key fingerprint is 45:b8:dc:fd:22:da:73:eb:db:e3:fb:89:7e:c8:0a:6e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'MyDestinationHost,' (RSA) to the list of known hosts.
[email protected]'s password:
SAF_OR_10M_T.dmp                              100% 3555MB   7.0MB/s   08:30


scp: ambiguous target caused by space in path

The below scp command will get you a scp: ambiguous target error message because of the spaces in the last argument.

scp -p "/tmp/Path With Space" user@host:"/tmp/Path With Space"

To resolve this issue, just quote the whole path of the last argument without forgetting the escape character.

Full example;

scp -p "/tmp/Path With Space" user@host:"\"/tmp/Path With Space\""

Discover More
Bash Liste Des Attaques Ovh
Linux - File

Linux file management See Using Parameters Expansion Removal From a path string where the file does not exist dirname returns the first parent of an existing path file. ...
Winscp Scp Ssh
Linux - WinScp Copy file from Windows to Linux

Winscp is a windows file manager that can make a ssh connection and use the SCP protocol. Just fill the needed information as below :

Share this page:
Follow us:
Task Runner