Scp stands for Secure Copy and is part of the SSH tool, which nearly every Linux distribution includes out of the box. That means you don’t have to install any extra software to get this done. And although at first blush using scp might be a bit confusing, it’s really not. I’m going to show you how it’s done, so you can push and pull files from one Linux machine to another. To do this, all you’ll need are two Linux machines. It doesn’t matter what distribution you’re using, but you will have to have user accounts on both machines (they don’t have to be the same user accounts, but you have to know the passwords for each account). It’ll be more clear in a moment.
Pushing a file from one machine to another
Let’s say you have the file zdnet_test on your local machine and you want to push it to another machine at IP address 192.168.1.30. To do this, log into the local machine and open a terminal window. Let’s say you have the same username on both the local machine and the remote machine. With that in mind, to push the zdnet_test file to the remote machine, you’d issue the command: Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine. You will be prompted for the user’s password and, upon successful authentication, the file will be copied. Now, let’s say you have a different user on the remote machine. In that case, the command would be: Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine. Again, you’ll be prompted for the user password before the file is copied. You could also push that file to a different directory (other than the user’s home directory). The one caveat to this is the user must have permission to write to the directory in question. Let’s say you want to copy that file to a directory on the remote machine, named /data. As long as the remote user has access to that directory, the command would be: Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine. Once again, you’ll be prompted for the user password before the file is copied.
Pulling a file from a remote computer
Let’s say the zdnet_test file is on a remote computer and you want to copy it to the local machine. To do that, you’d issue the command: Where /path/to is the full path to the zdnet_test file and USER is the username on the remote machine. And, yes, again you’ll be prompted for the user password before the file is copied. Like with pushing a file, you can also define the remote user and change the path to where the file will be saved. And that, my dear friends, is all there is to use the scp command on Linux. Enjoy this handy ability to push and pull files from one Linux machine to another, with the help of secure copy.