In the above example, since we’ve given “:” at the end of the ip-address and no other directory name after that, it will copy the vpn-setup.png to the home directory of ramesh username on the remote Linux server.

If you want to copy it to a different directory on the remote server. For example, to /tmp, do the following:

4. Copy from Linux to Windows (Remote to Local)

The following example transfer the file /home/ramesh/project.tar from the remote Linux server with ip-address 192.168.101.1 to the local Windows server. This copies the files to C:\Users\ramesh\Downloads directory on the local Windows laptop.

6. Use PuTTY Session Name in PSCP

If you are already using PuTTY, and have sessions stored, you don’t need to specify the username and ip-address in the pscp command. Instead you can just specify the PuTTY session name, and it will get the username/password from the PuTTY session automatically.

In the following example, it is using the PuTTY session dev-db, which already has the ip-address 192.168.101.1 and ramesh username associated with it. It will just use that to connect and transfer file automatically.

7. Preserve the Original Timestamp

When you copy files using pscp, by default, the transferred files will have the current date and time. You can keep the original file’s timestamp by using -p option, which will preserve the file’s attributes as shown below:

9. Use Batch Mode for Non-Interactive Copy

You can combine the key-based authentication (instead of password based) along with the -batch option to do non-interactive pscp between Windows and Linux servers. This is very helpful when you want to schedule some background tasks on your Windows machine to perform some routine file transfer jobs.

The following example will run the pscp in non-interactive mode by using the dev-db PuTTY session (which you should’ve already setup using key-based authentication).

C:\> pscp -batch dev-db:project.tar C:\Users\ramesh\Downloads

Please note that if pscp cannot authenticate with the given session, it will not give any error in the batch mode, it will just disconnect quietly. So, you should manually test this to make sure it is doing exactly what you are expecting it to do.

10. Use a Particular Protocol

SSH-2 is typically used with SFTP and SSH-1 is typically used with SCP.

However PSCP is smart. By default, it uses SSH-2 protocol to connect, when it fails, it then uses SSH-1 protocol.

You can force pscp to use either SSH-1 (scp) or SSH-2 (sftp) as shown below:

So, giving “-sftp” is optional. The following both are exactly the same (when SFTP is supposed on the destination Linux server):