Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Transfer files with SCP

Leer en espanol
Transfer files with SCP

Table of contents

The term SCP can ===

Secure Copy either SCP It is a means of secure transfer of computer files between a host local and a remote one or between two remote hosts, using the protocol SecureShell (SSH).

The term SCP can refer to two related concepts, the SCP protocol or the SCP program.

Much more information: Wikipedia

If we do a help we can see all the options it brings

Bash
rokitoh@red-orbita:~$ scp help

usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

[-l limit] [-o ssh_option] [-P port] [-S program]

[[user@]host1:]file1 … [[user@]host2:]file2

Copy from local computer to remote computer.

Bash
rokitoh@red-orbita:~$ scp Archivo Usuario@Servidor:RUTA

Example:

Bash
rokitoh@red-orbita:~$ scp red-orbita.jpg rokitoh@red-orbita.es:/home/rokitoh/

rokitoh@red-orbita.es’s password:

red-orbita.jpg                                                              100% 268KB 267.6KB/s 00:0

In this example we have copied an image called “red-orbita.jpg” through a user “rokitoh” to remote host red-orbita.es, this file will be saved in the directory/home/rokitoh/we would make the connection

In the opposite case that we want to copy from the remote host to our local computer it would be like this:

Bash
rokitoh@red-orbita:~$ scp Usuario@Servidor:Ruta/Archivo Ruta_Local

Example:

Bash
rokitoh@red-orbita:~$ scp rokitoh@red-orbita.es:/home/rokitoh/red-orbita.jpg /tmp/

rokitoh@red-orbita.es’s password:

red-orbita.jpg                                               100% 268KB 267.6KB/s 00:00

We can copy entire folders using the -r argument

Bash
rokitoh@red-orbita:~$ scp -r Archivo Usuario@Servidor:RUTA

Example:

Bash
rokitoh@red-orbita:~$ scp -r Documentos/ rokitoh@red-orbita.es:/home/rokitoh

rokitoh@red-orbita.es’s password:

rokitoh@red-orbita:~$

As in previous cases we have copied the directory “Documents” in the folder /home/rokitoh from the server red-orbita.es.

To do this process in reverse, downloading from the server to our computer is totally the same process as before.

Bash
rokitoh@red-orbita:~$ scp Usuario@Servidor:Ruta/Archivo Ruta_Local

Example:

Bash
rokitoh@red-orbita:~$ scp -r rokitoh@red-orbita.es:/var/ww /home/rokitoh

rokitoh@red-orbita.es’s password:

rokitoh@red-orbita:~$

Can also be copied from 2 remote hosts

Syntax:

Bash
rokitoh@red-orbita:~$ scp Usuario@Servidor1:/home/rokitoh/Archivo Usuario@Servidor2:/Ruta

Example:

Bash
rokitoh@red-orbita:~$ scp rokitoh@192.168.1.104/home/rokitoh/red-orbita.jpg operador@192.168.1.109:/home/operador

In this last example a file would be copied from the server 192.168.1.104 with the user rokitoh al servidor 192.168.1.151 with the user operator.

Well, that's all for now, in the next few days I will publish a small SSH manual and I will explain how to make connections without authenticating.

Greetings, rokitoh!


Comments