How to use SCP to transfer files between Linux and Raspberry PLC
Learn to use SSH with Industrial PLCs
30 julio, 2021 por
How to use SCP to transfer files between Linux and Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez


Odoo image and text block

INTRODUCTION


Sometimes, when we are testing our devices, we need to send files from our Linux based laptop to our Raspberry PLC so that we can execute them.

On other occasions, we have to do the opposite and send either files or directories from our Raspberry PLC to our laptop.

Now, you won't be to worry anymore about sending files through email, or pendrive or any other way that makes you loose time.

RELATED LINKS


How to connect Raspberry PLC to

Wi-Fi

 

Basics about Raspberry Pi based PLC Analog Outputs


How to find your perfect industrial Programmable Logic Controller

How to program a Raspberry Pi industrial PLC
Interrupt inputs with Python

Read >>

Open Source PLC Raspberry Pi
Family Products


Read >>

TouchBerry Pi
Family Products


Read >>

 EXPLANATION

SSH 

According to Wikipedia, the Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line, login, and remote command execution, but any network service can be secured with SSH.

SSH provides a secure channel over an unsecured network by using a client–server architecture, connecting an SSH client application with an SSH server. The protocol specification distinguishes between two major versions, referred to as SSH-1 and SSH-2. The standard TCP port for SSH is 22. SSH is generally used to access Unix-like operating systems, but it can also be used on Microsoft Windows. Windows 10 uses OpenSSH as its default SSH client and SSH server.


SCP 

SCP stands for secure copy, which is a command-line utility that allows you to securely copy files and directories between two remote locations, from local to remote system and from remote to local system.


If you type the command below, you will see the following information:

man scp

Scp copies files between hosts on a network.  It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh.  scp will ask for passwords or passphrases if they are needed for authentication.

The source and target may be specified as a local pathname, a remote host with optional path in the form [user@]host:[path], or a URI in the form scp://[user@]host[:port][/path].  Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers.

When copying between two remote hosts, if the URI format is used, a port may only be specified on the target if the -3 option is used.



First of all, check that your SSH is activated:

sudo systemctl status ssh.service


If it is not, start it:

sudo systemctl start ssh.service


Then, we must have clear that the structure is always the same, with optional options after scp:

Odoo image and text block

Assuming the following information about Raspberry PLC:

- User: pi

- Eth IP Address: 10.10.10.20

- Wlan IP Address: 192.168.1.2

Let's see some examples!


Copy From Remote to Local Host

scp pi@10.10.10.20:/home/pi/sample-file-from-raspberry.txt /home/user/file-in-linux-laptop.txt
scp pi@192.168.1.2:/home/pi/sample-file-from-raspberry.txt /home/user/file-in-linux-laptop.txt


Copy From Local to Remote Host 

scp -r /home/user/test-directory pi@10.10.10.20:/home/pi/
scp scp -r /home/user/test-directory pi@192.168.1.2:/home/pi/


Checkout the manual for more options and information about scp

man scp

How to use SCP to transfer files between Linux and Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
30 julio, 2021
Compartir
Archivar

¿En busca de tu PLC ideal?

Echa un vistazo a esta comparativa de producto de varios controladores industriales basados en Arduino.

Comparamos entradas, salidas, comunicaciones y otras especificaciones con las de los equipos de otras marcas destacadas.


Comparativa PLC industrial >>

¿Quieres más información?

¡Rellena el formulario!

¡Cuéntame más!