In this guide, you will learn how to securely transfer files and folders between Windows and Linux machines using the SCP (Secure Copy Protocol) command. SCP uses SSH for data transfer, providing the same authentication and security as the Secure Shell protocol.
Before transferring files, ensure that both your Windows and Linux machines have an OpenSSH Server installed and running. This is required to accept the incoming connection.
Use the PowerShell command Test-NetConnection (or the alias tnc) to verify that the target machine is reachable on port 22 (SSH).
tnc 192.168.1.5 -port 22
If the TcpTestSucceeded result is True, the SSH service is active and accessible.
We will initiate the transfer from the Windows machine PowerShell terminal.
The basic syntax for transferring a file is: scp [source_file] [user]@[remote_host]:[destination_path].
scp file.iso linuxtest@192.168.1.5:/home/linuxtest/
You will be prompted for the Linux user's password. Once authenticated, the transfer will begin.
To transfer a directory and all its contents, you must add the -r (recursive) flag.
scp -r folder_name linuxtest@192.168.1.5:/home/linuxtest/
You can also pull files from a Linux machine back to Windows, or push them from Linux. Here, we demonstrate pushing from the Linux terminal to Windows.
When specifying the Windows destination path in SCP, you must use forward slashes (/) instead of the standard Windows backslashes (\), and the drive letter is often formatted as a path component.
scp -r folder_name wintest@192.168.1.10:C:/test/
If a transfer fails or hangs, you can use the -v (verbose) flag to see detailed debug information about the connection, authentication, and transfer process.
scp -v file.iso wintest@192.168.1.10:C:/test/
This is extremely useful for diagnosing errors such as "No such file or directory" if you mistype the destination path.