How to Copy File From Windows to Linux Using SSH [2 Methods]

Want to copy and transfer files and folders securely from Windows to Linux using SSH? SCP (Secure Copy) can be the finest tool in this case. It actually works within SSH (Secure Shell) protocol and demonstrates a secure and high-speed data transfer from one computer to another over an unsecured network. To transfer data from Windows to SSH, you must have OpenSSH server. In this guide, I will describe how to copy file from Windows to Linux over SSH using the SCP tool on Windows 10. Explore and follow the guide manually.

Process flow chart to copy file from Windows to Linux using SSH:Flowchart on copying files from Windows to Linux using SSH

[Distro & Windows Used Throughout the Tutorial: Ubuntu 22.04.2 LTS & Windows 10]

2 Methods to Copy File From Windows to Linux Using SSH

If you want to make the SCP tool work on your Windows, there must be a running OpenSSH server on your Linux system to where you want to transfer files and folders. Here is how to get the SSH server installed:

sudo apt install openssh-server
EXPLANATION
  • sudo: Super User DO.
  • apt install: Advanced package utility.
  • openssh-server: Open source secure shell server permits remote users to access server.

Installing SSH serverAs everything is set up now, I’ll cover two methods to copy and transfer files from Windows to Linux securely in this guide.

You can go through the Comparative Analysis of Methods to know about the pros and cons of the used methods.

1. Using PowerShell to Copy File From Windows to Linux Using SSH

By default, SCP is built into Windows 10 PowerShell. You don’t have to install it separately. You can use SCP in PowerShell directly by following the steps below:

  1. Open Windows File explorer and copy the file location you want to copy from Windows to Linux.
  2. Now, open PowerShell and write cd and paste the copied file location like below and hit ENTER.
    cd C:\Users\User\Downloads
    EXPLANATION
    • cd: Navigates to assigned folder.
    • C:\Users\User\Downloads: The location of the file/folder.
  3. Then, use the SCP command like the following syntax:
    SCP colors.txt [email protected]:/home/nadiba/Desktop
    EXPLANATION
    • SCP: It allows secure file transfer between the hosts on a network.
    • colors.txt: The file you want to transfer. Here, I want to transfer the ‘colors.txt’ file.
    • [email protected]:/home/nadiba/Desktop: Replace ‘nadiba’ with your Linux username, replace ‘192.168.231.128’ with your LAN IP address or hostname, replace ‘/home/nadiba/Desktop’ with the folder where you want to transfer the file.
  4. Writing command and copying file from PowerShell

  5. Open Files on your Ubuntu and go to home>nadiba>Desktop to check the copied file.Opening the transferred file on Ubuntu to check You can see from the above image that the file ‘colors.txt’ has been transferred to the Linux system.

Read More: How to Share Files between Linux and Windows

2. Using SFTP Client to Copy File From Windows to Linux Using SSH

For Windows, there are several SFTP clients available like WinSCP, FileZilla, Cyberduck, PuTTY etc. Among them, WinSCP can be a better option to transfer files from Windows to Linux when you want to avoid syntax complexity. It provides a convenient GUI interface. Here’s how to use WinSCP to copy files:

  1. Download and install WinSCP on your PC.

    Note: To download WinSCP for file transfer follow the link: Winscp.net
  2. Now, launch it and you will see a Login window.Entering file protocol, hostname, name, user-password in login windowIn the File protocol section, replace SFTP with SCP. Also, enter the hostname, username, password and click Save. Then, there will prompt a new window like the following image:Saving the entered inputsPress OK and then click Login.Clicking on 'Login' to proceed
  3. Now, there will prompt a window asking ‘Continue connecting to an unknown server and add its host key to a cache?’. Click Yes.Clicking 'Yes' to the prompted window ‘Continue connecting to an unknown server and add its host key to a cache?’
  4. Then, put your user password again for authentication.Authenticating by putting password again
  5. Open File explorer on Windows, browse a file and drag the file into WinSCP’s window. The file will be shared instantly to the remote Linux PC. Selecting file in Windows to copyDragging & transferring file to Linux Here, I want to share an image file named ‘samba.png’. So, I dragged it into the WinSCP window and you can see that the file is transferred to Linux.

Read More: How to Share Files between Linux and Windows Dual Boot [3 Methods]

Comparative Analysis of Methods to Copy File from Windows to Linux Using SSH

When it comes to copying files from Windows to Linux over SSH, you can use either PowerShell or SFTP client. Let’s make a comparative analysis between these two methods:

Methods Pros Cons
Method 1
  • SSH supported.
  • Flexibility.
  • Error-handling, logging capability.
  • Syntax complexity.
  • Limited custom options.
Method 2
  • User-friendly interface.
  • No syntax complexity.
  • Supports multiple file transfer protocols.
  • Less integration.
  • Limited features.

Overall, both methods are preferable with their individual capabilities. It’s your choice to select one which meets up your needs and preferences.

Conclusion

While working on Windows, transferring files to Linux machines is quite a common task. In the article, I have introduced different methods to copy files from Windows to Linux through SSH protocol. Hope you’ll be benefited from this guide.

People Also Ask

What is SSH file transfer?

SSH file transfer, or SFTP (SSH File Transfer Protocol), is a secure and encrypted network protocol for transferring files between computers over a secure shell (SSH) connection. SFTP ensures data confidentiality by encrypting both authentication credentials and the transferred files. It operates on the standard SSH port (usually 22) and provides a secure alternative to traditional FTP for remote file management, administration, and data exchange between systems.

How does transferring files over SSH work?

The mechanism of transferring files over SSH depends on which type of method is being employed. For instance:

When initiating a file transfer, the client establishes a secure SSH connection to the server. This connection is encrypted to prevent unauthorized access or data interception. Authentication is typically performed using a username and password or, more securely, with SSH key pairs.

For SFTP, a separate channel is established within the SSH connection dedicated to file transfer. The client and server negotiate encryption algorithms and keys for this data channel. Once the secure channel is set up, file data and commands are exchanged through it.

In the case of SCP, the file transfer is integrated with the SSH protocol. SCP piggybacks on the SSH connection, utilizing the same authentication and security mechanisms. Files are transferred over the encrypted SSH connection without the need for a separate data channel.

Why should I use SSH for file transfers?

SSH uses for file transfers due to its robust security features. When you transfer files over SSH, the entire process is encrypted, preventing unauthorized access and safeguarding the integrity of your data. SSH uses strong authentication mechanisms, including the option for secure key-based authentication, adding an extra layer of protection compared to traditional methods like FTP.

Does SCP work on Windows?

Yes, SCP (Secure Copy Protocol) can work on Windows. While SCP aligns with Unix-like operating systems, you can use it on Windows with the help of third-party tools. One popular tool for enabling SCP on Windows is PuTTY, a suite of utilities for secure communication.

PuTTY includes a command-line tool called pscp (PuTTY Secure Copy) that functions similarly to the native SCP on Unix-like systems. To use pscp, you need to download and install PuTTY on your Windows machine. Once installed, you can open a Command Prompt and use the pscp command to securely copy files between Windows and remote systems that support SSH.

To securely copy the specified file from your Windows machine to the specified location on the Linux server using pscp, use the code below:

pscp C:\path\to\your_file.txt username@your_linux_server_ip:/path/on/linux/server

Replace the file path, username, server IP, and destination path according to your setup.

Does PowerShell have SCP?

No, PowerShell does not have native support for SCP (Secure Copy Protocol). However, you can leverage SSH (Secure Shell) in PowerShell to achieve secure file transfers. The WinSCP module is a popular choice for SCP-like functionality in PowerShell. It allows you to connect to remote servers using SSH and transfer files securely. You can use the Get-SFTPFile and Send-SFTPFile cmdlets provided by the WinSCP module to perform SCP-like file transfers in PowerShell. Install the module using the Install-Module cmdlet and then use the cmdlets to interact with remote servers over a secure connection.

Does SCP work on Internet?

Yes, SCP (Secure Copy Protocol) can work over the Internet. SCP operates over SSH (Secure Shell), providing a secure and encrypted channel for file transfer. When using SCP over the Internet, you typically connect to the remote server using its public IP address or domain name. The communication between your local machine and the remote server is encrypted, ensuring the confidentiality and integrity of the transferred files.

Does SCP have a limit?

Yes, SCP has a size limit. The maximum size allowed for an SCP document is 5,120 characters which includes all characters, including white space. However, To fit your SCP within this limit, you can remove all white space characters like spaces and line breaks which are not inside quotation marks.

Related Articles 

Rate this post
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
Nadiba Rahman

Hello, This is Nadiba Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation with a bachelor’s degree in Electronics & Telecommunication Engineering from Rajshahi University of Engineering & Technology (RUET).I am quite passionate about crafting. I really adore exploring and learning new things which always helps me to think transparently. And this curiosity led me to pursue knowledge about Linux. My goal is to portray Linux-based practical problems and share them with you. Read Full Bio

Leave a Comment