How to transfer a file over network

Stable: 24.06.2022 - 14:29 / Revision: 24.06.2022 - 14:28

I am here to prevent the first-page-empty bug!

Template:ReviewersList Template:ArticleApprovedVersion


1 Article purpose

The article aims to give some information useful to start with the scp Linux command.

2 Introduction

The scp[1] copies files between hosts on a network. It uses ssh[2] (remote login program) for data transfer, uses the same authentication and provides the same security as ssh.

This article focuses on the file transfer between a host PC and a STMicroelectronics board over a network connection.

3 Installation on your target

The scp is installed on the STMicroelectronics images via the package openssh.

4 Installation on your PC

The package openssh-client must be installed on your host PC to perform a file transfer over network with the scp.

On Ubuntu:

 sudo apt-get install openssh-client

5 Getting started

  • Your host PC and your board are connected to your local network through
  • Upload a file (<host file path>/<example.txt>) from your host PC to your board:
 scp <host file path>/<example.txt> root@<board ip address>:/<board file path>/
Example (assuming that <board ip address> is a.b.c.d):
 Copy the example.txt host PC file in the /home/root/ board directory
  echo "scp example: from host PC to board" > ./example.txt
  scp ./example.txt root@a.b.c.d:/home/root

 Check the result on the board 
  cat /home/root/example.txt 
 scp example
  • Download a file (/<board file path>/<example.txt>) from your board to your host PC:
 scp root@<board ip address>:/<board file path>/<example.txt> <host file path>/
Example (assuming that <board ip address> is a.b.c.d):
 Copy the example.txt board file in the current directory of the host PC
  echo "scp example: from board to host PC" > /home/root/example.txt
  scp root@a.b.c.d:/home/root/example.txt ./

 Check the result on the host PC
  cat ./example.txt
 scp example: from board to host PC

6 References

IMPORTANT NOTICE – READ CAREFULLY
STMicroelectronics NV and its subsidiaries ("ST") reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgment.

Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of purchasers’ products.

No license, express or implied, to any intellectual property right is granted by ST herein.

Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.

ST and the ST logo are trademarks of ST. For additional information about ST trademarks, refer to www.st.com/trademarks. All other product or service names are the property of their respective owners.

Information in this document supersedes and replaces information previously supplied in any prior versions of this document.