• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

How to Use SCP: Transfer Files from Local to Remote

Bhagwad Park

Published on: June 12, 2024

Categories: Linux Command Line, VPS Hosting 0

While SSH is a way to log into a remote server from your local machine, it’s not a way to transfer a file from your local computer to the remote server. An SSH session works within the context of the remote server’s file system, and it doesn’t have any access to the files on your desktop. However, the SSH protocol is very useful, and we can use it to transfer files securely.

The way to do this is by using the SCP – Secure Copy Protocol. While it’s a separate tool, it leverages the underlying SSH protocol to securely transfer files in an encrypted manner, in a way that can’t be intercepted by anyone en route.

Table of Contents
  • Using SCP on Windows, Linux, and macOS
  • Allowing Passwords on the Remote Server Makes it Easy
  • Transferring Files from Local to Remote via SCP
  • Confirming the Key Fingerprint
  • Enter your Password
  • Removing Windows’ Memory of the Server
  • Using PuTTY Instead of SCP
  • Conclusion

Using SCP on Windows, Linux, and macOS

Traditionally, the “scp” command was only available on Linux and macOS by default, and Windows users had to either install the OpenSSH suite or use another program like “pscp” from PuTTY. However, the latest versions of Windows 11 allow you to use the “scp” command directly from the command line. This makes scp easily accessible to anyone without the need for 3rd part software.

Allowing Passwords on the Remote Server Makes it Easy

In an earlier series of articles, I had extolled the virtues of disabling passwords on your root server and forcing users to use SSH keys to log in instead. That advice still holds today. Using public/private keys to log in is safer, and more convenient once you’ve set up the process.

However, when connecting to the server for ad-hoc purposes like transferring files from a local to the remote directory, the wiring up of the public/private keys can present a headache that’s not worth the effort – particularly if you’re not going to be doing it often. So for this tutorial, I’m going to assume that your remote server is protected with a password, and not a pair of SSH keys. If your server uses SSH keys to log in, see if you can temporarily disable them so that you can log in with passwords only for the time it takes you to transfer the files.

Transferring Files from Local to Remote via SCP

To make the transfer, you’ll need the following pieces of information:

  1. Full path to the file on the local computer
  2. Your login credentials on the remote server
  3. The IP address or the domain name of the remote server
  4. The path to the folder on the remote destination server

For this example, I’ve created a file called “Test-File.txt” on my desktop. On Windows 11, I can open the command line and start using the “scp” command right away. Here’s the syntax:

 scp Test-File.txt [Username]@[IP Address]:[Destination Directory]

In the above command replace the following:

  1. [Username]: Your username on the remote server
  2. [IP Address]: Your remote server’s IP address
  3. [Destination Directory]: The path to the destination folder on the remote server

In this example, I’ve opened the terminal in the same location as the file I want to transfer – “Test-File.txt”, so I don’t need to specify the origin path. To make things easy on yourself, I suggest you do the same. Open the terminal either directly at the location of your files or first navigate to the file’s location. This way you won’t have to enter more information in the terminal than you have to.

Confirming the Key Fingerprint

If this is the first time that you’re connecting to the remote server, Windows will throw a warning saying that it doesn’t recognize the key fingerprint of the remote server. This is a precautionary measure meant to protect you against man-in-the-middle attacks, where a 3rd party tries to spoof the destination server, making you think that you’re connected when in reality you’re not.

If you’re sure that you’ve entered the IP address of the server correctly, type “yes” to confirm to your local machine that the destination server is safe.

Enter your Password

Once you’ve confirmed that the key signature you see is the one belonging to the remote server to which you want to connect, then you have to enter the password corresponding to the username that you entered while executing the SCP command. If everything goes well, the command will execute like this:

Using SCP on Windows
Using SCP on Windows

As you can see, the system first asked me to confirm the key fingerprint of the server, and then asked me for my password. The file I was trying to transfer was just an empty text file, so it didn’t have any size. However, you can see from the screenshot below that the file now exists on the remote server after I SSH into it:

File Transferred
File Transferred

It’s that easy!

Removing Windows’ Memory of the Server

As mentioned above, when you connect to the server for the first time, the system asks you if you recognize the key fingerprint of the remote server. This is to defend you against man-in-the-middle attacks, where a server spoofs the real one and pretends to be something else. If you know what you’re doing, and have checked the IP address, you’re probably fine, so you just type “yes” and carry on. Windows will then save the key fingerprint of the remote server in the “.ssh/known_hosts file so that it won’t have to ask you the same question the next time you log in.

However, there are times when you might want to purge the memory of your local PC so that it “forgets” the remote server and forces it to ask you the next time you connect. I wanted to do this myself to write this tutorial so that I could take screenshots of the scp tool asking me if I recognized the remote server. Fortunately, removing the key signature is easy. Just enter the following command on Windows:

ssh-keygen -R <remote_server_ip_or_hostname>

This will generate the following output:

Removing the Memory of the Server
Removing the Memory of the Server

The ssh-keygen tool will remove the entry from the .ssh/known_hosts file and will force the system to ask you for permission the next time you connect using SSH or SCP.

Using PuTTY Instead of SCP

As an alternative to the in-built SCP tool that comes with Windows, you can use PuTTY. This isn’t the first time I’ve referenced putty on this NameHero blog. It’s even part of the toolkit in the article for adding SSH keys which I linked earlier. PuTTY has an SCP tool called “pscp.exe”, and you can download it as a standalone file on the download page and invoke it when you want to transfer files using the SCP protocol.

PuTTY was particularly useful on older versions of Windows that didn’t have access to the OpenSSH tools. But it has already acquired such a large user base that many people will continue to use it out of habit. The syntax is more or less identical to that used by the SCP tool on Windows, so switching between the two is easy.

If you’re using a later version of Windows, though, I would suggest sticking to the default scp tool that comes with the command line. That way you won’t have to keep track of another program.

Conclusion

Using SCP to transfer files from your local to the remote system is easy. The SCP protocol is built on top of SSH, which means that it provides a fully encrypted channel for file transfers.

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Docker Build Cache – How it Works and Invalidating it

Docker heavily optimizes its build process with caching to save time. But it's important to know how to invalidate it.

Curl vs Wget: Choosing the Right Tool for the Job

Linux has two popular tools for getting data from third party websites. Here's the difference between curl and wget.

How to Use the xargs Command in Linux

The "xargs" command converts text from standard input into arguments, allowing the output for one command to be used as arguments in other.

How to Use the Bash Select Loop in Linux

The bash select loop allows your Linux script to present a set of choices to the user as a menu. Here's how to use it.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA