When developing on embedded Linux systems, there is often need to transfer files back and forth between the embedded device and other computers. This is especially true when using cross compiling as the development cycle may require numerous iterations of compiling a program on the build machine and testing it on the embedded device. One useful tool for transferring files is the secure copy (scp) command. This command is part of the OpenSSH package which can be installed on almost any embedded Linux device.
Using the scp command is similar to using the standard copy (cp) command. One difference is that scp supports a syntax for specifying remote paths. The syntax is illustrated in the following example:
scp [email protected]:/absolute/path/to/file.x
In the syntax, a remote target is specified along with an absolute path on the remote target. These are separated by a colon. The remote target contains a username and a host name (which can be an IP address) separated by the @ symbol. When the scp command is run, it will attempt to connect to the remote target using the SSH protocol on the standard SSH TCP port (22). If it connects, it will prompt for the remote user’s password. On entering the correct password, it will transfer the file.