Sometimes, when you are testing our devices, you need to send files from your Linux-based laptop to your industrial Raspberry PLC so that you can execute them.
Other times, you have to do the opposite and send either files or directories from your industrial Raspberry Pi PLC to your laptop.
Now, you no longer have to worry about sending files through email, or pendrive or any other way that makes you lose time. In this post, we explain you how to do it automatically thanks to industrial automation and industrial control.
SSH provides a secure channel over an unsecured network by using 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 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 a remote system and from remote to a local system.
If you type the command below, you will see the following information:
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 path name, a remote host with an 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 path names 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:
Assuming the following information about an Open Source PLC Raspberry 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 email@example.com:/home/pi/sample-file-from-raspberry.txt /home/user/file-in-linux-laptop.txt
scp firstname.lastname@example.org:/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 email@example.com:/home/pi/
scp scp -r /home/user/test-directory firstname.lastname@example.org:/home/pi/
Check out the manual for more options and information about SCP: