Copy Files From Windows to Linux Using PowerShell

Rohan Timalsina Dec 21, 2022 Jun 06, 2022
  1. Use scp Command to Copy Files From Windows to Linux in PowerShell
  2. Use pscp Command to Copy Files From Windows to Linux in PowerShell
Copy Files From Windows to Linux Using PowerShell

The SSH (Secure Shell) is introduced in PowerShell 6.0. It helps create and establish a PowerShell session remoting between two hosts to share data.

The best part of SSH-based remoting in PowerShell is that it allows remoting between Windows and Linux computers. The SSH should be installed and configured on both local and remote computers.

This tutorial will teach you to copy files from Windows to Linux machine using PowerShell.

Use scp Command to Copy Files From Windows to Linux in PowerShell

The scp is a command-line tool to copy files or folders between hosts on a network. It uses the SSH protocol for securely transferring data from one computer to another.

The following command copies the test.txt file from the Windows computer to the Linux computer. It copies test.txt from the current directory to the /home/delftstack directory of the Ubuntu system.

scp test.txt delftstack@ubuntu-PC:/home/delftstack/

It will prompt you to enter the user password of the specified remote computer.


delftstack@ubuntu-pc's password:
test.txt                                                                              100%  960   961.6KB/s   00:00

The above output shows that the test.txt file is successfully copied from Windows to the Ubuntu system.

You have to use the -r flag to copy the entire folder. This command copies the folder C:\New\complex and its content to a remote computer in the directory /home/delftstack/.

scp -r C:\New\complex delftstack@ubuntu-PC:/home/delftstack/


delftstack@ubuntu-pc's password:
formula.png                                                                           100%   32KB  16.2MB/s   00:00
modules.png                                                                           100%   54KB  26.6MB/s   00:00
output paper.png                                                                      100%  186KB  62.1MB/s   00:00
report.docx                                                                           100% 1604KB  69.9MB/s   00:00
sample output.png                                                                     100%   67KB  33.2MB/s   00:00

The scp command is an easy and quick way to transfer files and folders from the local computer to the remote computer.

Use pscp Command to Copy Files From Windows to Linux in PowerShell

pscp is an alternative tool for SCP. It is a similar tool used for transferring files securely between computers using an SSH connection.

It can be used after installing PuTTY on the computer. Go to this page and download the latest version of PuTTY on your system.

After installing the PuTTY, you should be able to use the pscp command in PowerShell. The following example uses the pscp command to copy the styles.csv file to the remote directory /home/delftstack/New Folder.

pscp styles.csv delftstack@ubuntu-PC:"/home/delftstack/New Folder"


delftstack@ubuntu-PC's password:
styles.csv                | 4273 kB | 4273.1 kB/s | ETA: 00:00:00 | 100%

Use the -r flag to copy the entire directory to the remote computer.

pscp -r C:\record delftstack@ubuntu-PC:/home/delftstack/


delftstack@ubuntu-PC's password:
AI.png                    | 380 kB | 380.2 kB/s | ETA: 00:00:00 | 100%
aireport.docx             | 1534 kB | 1534.3 kB/s | ETA: 00:00:00 | 100%
python_mcq.pdf.pdf        | 2590 kB | 2590.1 kB/s | ETA: 00:00:00 | 100%
weatherHistory.csv        | 5254 kB | 5254.5 kB/s | ETA: 00:00:00 | 100%

In this article, you have learned two methods for copying files and folders from Windows to Linux computers. You should know how to transfer files between Windows and Linux systems using PowerShell.

Rohan Timalsina avatar Rohan Timalsina avatar

Rohan is a learner, problem solver, and web developer. He loves to write and share his understanding.

LinkedIn Website