October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Use the scp Command to Copy Files to a VPS

A practical scp guide for VPS transfers: upload, download, copy folders, select SSH keys, use custom ports and bastions, handle permissions, and diagnose failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use scp with the local path first and the VPS path second:

scp ./local-file.txt [email protected]:/home/deploy/

The command connects over SSH, authenticates as the specified VPS user, and transfers the file. For downloads, reverse the order. Use -i for a particular SSH key, uppercase -P for a non-standard port, and -r for a directory tree. The destination directory must already exist and be writable by the account you use.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What scp does when you copy to a VPS

The OpenSSH project describes scp as a command that “copies files between hosts on a network.” A VPS is simply the remote host in this command. You identify it with a DNS name or IP address, an SSH login user, and, when necessary, a port and private key.

Current OpenSSH implementations run the transfer through SSH and use the SFTP protocol by default. That means scp uses the same encrypted connection and authentication as an SSH login; it does not create a separate password or encryption system. The legacy scp protocol is selected only with the -O compatibility option.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Every transfer has two endpoints:

  • Local: a path on the computer where you run the command.
  • Remote: [user@]host:path, or an equivalent scp:// URI.

The general form is:

scp [options] source target

For an upload, the source is local and the target is remote. For a download, the remote path is the source and your local path is the target.

Prerequisites before the first transfer

Have these details from your VPS setup:

  • The VPS DNS name or IP address.
  • The login username, such as deploy.
  • The SSH port. It is often the default SSH port, but your server may use another one.
  • The local path to the private key, if the server requires key authentication.
  • A remote directory that the login user can write to.

First test the login itself. Substitute the same user, host, port, and key that you intend to use with scp:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ssh -i ~/.ssh/id_ed25519 -p 2222 [email protected]

If this command cannot connect, fix the SSH connection before investigating a file path. Check the hostname or IP address, firewall rules, port, username, and key selection. A successful SSH login confirms that the network route and authentication details are usable for scp too.

Upload one file to your VPS

Copy a file into a remote directory

Run this locally:

scp ./local-file.txt [email protected]:/home/deploy/

./local-file.txt is the source on your computer. The part before the colon identifies the VPS and account. The path after the colon is the destination directory. When the trailing destination is a directory, the original filename is retained.

Upload and rename in one command

Give the destination a filename instead of a directory:

scp ./build/app.tar.gz [email protected]:/tmp/app-release.tar.gz

The local file is stored on the VPS as /tmp/app-release.tar.gz. The parent directory must exist, and your account must be allowed to create or replace that file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm the uploaded file

After the transfer, inspect the remote path through SSH:

ssh [email protected] 'ls -l /tmp/app-release.tar.gz'

This verifies both the spelling and the final location without relying on the progress display from scp.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Download a file from the VPS

Put the remote path first and a local directory second:

scp [email protected]:/var/log/app.log ./logs/

The file is copied from /var/log/app.log into the local ./logs/ directory. The local directory must already exist. To choose a different local filename, specify the full target path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
scp [email protected]:/var/log/app.log ./logs/app-from-vps.log

Remote paths are interpreted on the VPS. Local paths are interpreted by the shell on the computer running scp.

Copy a directory recursively

Add -r when the source is a directory:

scp -r ./site [email protected]:/var/www/

This copies the site directory and its contents below /var/www/. The manual notes that symbolic links encountered while traversing a directory with -r are followed, so check the tree if it contains links that point outside the directory you intended to transfer.

You can also download an entire remote directory:

scp -r [email protected]:/home/deploy/releases ./

Recursive copying is convenient for small deployment trees. For a very large tree, consider whether transferring an archive as one file better suits your workflow; scp itself does not provide a separate synchronization or resume command.

Use an SSH key with scp

Select a private key explicitly

Use -i followed by the private-key path:

scp -i ~/.ssh/id_ed25519 ./backup.tar.gz [email protected]:/home/deploy/

The option selects the identity file used for public-key authentication. Keep the private key on your local computer. It should never be copied to the VPS as part of a file-transfer workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your SSH configuration already selects the right key for a host alias, you can omit -i and use that alias. When a transfer unexpectedly asks for a password or reports an authentication failure, specify the key explicitly and test the same combination with ssh.

Combine a key with other connection options

Options can be placed together before the source and target:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
scp -i ~/.ssh/id_ed25519 -P 2222 -r ./site [email protected]:/var/www/

This selects the private key, connects to port 2222, and recursively uploads the site directory.

Connect through a custom SSH port or jump host

Use a non-standard port

Use uppercase -P:

scp -P 2222 ./backup.tar.gz [email protected]:/home/deploy/

-P selects the remote SSH port. Case matters: lowercase -p has a different purpose and preserves source modification times, access times, and mode bits. Confusing these options can send the command to the wrong port or preserve metadata when you did not intend to.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a bastion host with ProxyJump

If the VPS is reachable only through an intermediary host, use -J exttt{} with the jump account and address:

scp -J [email protected] ./local-file [email protected]:/home/deploy/

The connection first uses the bastion as a jump point and then reaches the VPS. The destination account remains deploy; the jump account is only for the intermediary connection.

Pass another SSH setting with -o

The -o option passes an SSH configuration setting. For example, if your environment has a host-specific SSH option configured, you can supply it on the command line in the same way you would with ssh. Keep the source and target after all options so the command is easy to audit.

Choose and verify the destination path

Upload to a user-owned directory first

Protected locations such as /var/www commonly reject writes from an ordinary deployment account. Upload to a directory owned by that account, then move the file with a privileged SSH command:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
scp ./app.tar.gz [email protected]:/home/deploy/
ssh [email protected] 'sudo install -m 0644 /home/deploy/app.tar.gz /var/www/app.tar.gz'

The first command performs the file transfer as deploy. The second runs install with sudo and places the file at the protected path with mode 0644. This separates network transfer from the privileged operation; scp does not itself become root on the VPS.

Check that a directory exists and is writable

Inspect the remote directory before retrying a failed upload:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
ssh [email protected] 'pwd; ls -la /home/deploy/'

For another destination, replace the path in the command. If the directory is missing, create it through an SSH session with an account authorized to do so. If it exists but is not writable, correct its ownership or permissions or choose a directory the login user owns.

Avoid colon ambiguity in local paths

The colon separates a remote host from its path. A local filename containing a colon can therefore be interpreted as a host specification. This matters especially with Windows-style names such as C:UsersNamefile.txt when they are passed unquoted through a shell that recognizes the colon syntax.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use an explicit relative or absolute local path, or quote the path according to the shell you are using. For example, a local path beginning with ./ clearly identifies the source as local:

scp ./file.txt [email protected]:/home/deploy/

Useful scp options

Option Purpose When to use it
-i identity_file Selects a private key for public-key authentication. Use when the required key is not selected automatically by your SSH configuration.
-P port Selects the remote SSH port. Use for a VPS listening on a port other than the default.
-r Recursively copies directories. Use when the source or target is a directory tree.
-p Preserves modification times, access times, and mode bits. Use when source metadata must be retained.
-C Enables SSH compression. It can help with compressible text over a slow link; already-compressed archives may gain little.
-q Suppresses the progress meter and diagnostics. Use only when quiet output is required; omit it during troubleshooting.
-v Increases SSH diagnostic output. Use to inspect connection, authentication, and negotiation details.
-l KBIT Limits transfer bandwidth in kilobits per second. Use when the copy must not consume the entire available link.
-J jump_host Uses a bastion through SSH ProxyJump. Use when the VPS is reachable through an intermediary host.
-O Selects the legacy scp protocol instead of the current SFTP-based behavior. Use only for a documented compatibility requirement.

For example, to upload a text-heavy directory through a key-authenticated server on port 2222 while limiting bandwidth:

scp -i ~/.ssh/id_ed25519 -P 2222 -C -l 20000 -r ./site [email protected]:/home/deploy/

The limit is expressed in kilobits per second. Remove -C for an archive or other data that is already compressed.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Platform notes for local paths

Linux and macOS shells

Use relative paths such as ./build/app.tar.gz or absolute paths such as /Users/name/build/app.tar.gz. Quote a path when spaces or shell metacharacters are present:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
scp "./release builds/app.tar.gz" [email protected]:/home/deploy/

The quoting rules belong to your local shell; scp receives the resulting path.

Windows OpenSSH environments

OpenSSH clients on Windows accept Windows paths, but the colon in a drive-letter path can conflict with scp’s host-and-path syntax when the path is not clearly local. Use the path form required by your shell and quote it where appropriate. A relative path such as ./app.tar.gz avoids that ambiguity. If a path contains spaces, quote the entire local argument.

A repeatable deployment workflow

For routine releases, use the following sequence so connection problems and permission problems are separated:

  1. Confirm the connection: run ssh with the intended user, key, host, and port.
  2. Check the destination: verify the remote directory with pwd and ls -la.
  3. Transfer to a writable staging path: upload the archive or build output under the login user’s home directory.
  4. Verify the file: use SSH to inspect its size, name, and location.
  5. Install into a protected path if necessary: use an authorized sudo install command, setting the required mode.
  6. Keep diagnostics available: do not use -q while validating a new workflow.

A concrete release example is:

ssh -i ~/.ssh/id_ed25519 -p 2222 [email protected]
scp -i ~/.ssh/id_ed25519 -P 2222 ./app.tar.gz [email protected]:/home/deploy/
ssh -i ~/.ssh/id_ed25519 -p 2222 [email protected] 'ls -l /home/deploy/app.tar.gz'
ssh -i ~/.ssh/id_ed25519 -p 2222 [email protected] 'sudo install -m 0644 /home/deploy/app.tar.gz /var/www/app.tar.gz'

Using the same connection parameters in every step prevents a successful login test from being misleading when the transfer uses a different key or port.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common scp failures

“Permission denied”

This usually means either authentication failed or the authenticated account cannot write to the destination. First run the matching SSH command:

ssh -i ~/.ssh/id_ed25519 -p 2222 [email protected]

If SSH itself rejects the key or account, correct authentication. If SSH succeeds but the copy is rejected, upload into a user-owned directory such as /home/deploy, then move the file with an authorized privileged command. Do not attempt to solve a remote filesystem permission problem by copying your private key to the VPS.

“No such file or directory”

Check both sides of the transfer. On the local computer, confirm the source path and filename. On the VPS, inspect the destination and its parent directory:

ssh [email protected] 'pwd; ls -la /path'

Pay attention to capitalization, spelling, and whether you intended a directory or a complete destination filename.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connection timeout or refused

Verify the DNS name or IP address, firewall rules, SSH port, and username. If the server uses port 2222, scp must include uppercase -P 2222. A wrong port can look like a server outage.

Authentication uses the wrong key

Specify the intended identity explicitly with -i and use the same key in the SSH test. Keep the private key local and protect its file permissions. If your SSH configuration has several identities, explicit selection makes the transfer predictable.

The host-key prompt is unexpected

On a first connection, SSH may ask you to verify the server’s host-key fingerprint. Confirm that fingerprint through a trusted VPS provider console or documentation before accepting it. Do not approve an unfamiliar fingerprint merely to make the command continue.

Diagnostics are too limited

Remove -q and add -v:

scp -v -i ~/.ssh/id_ed25519 ./file.txt [email protected]:/home/deploy/

The verbose output exposes connection and authentication negotiation details. Use it to distinguish a network or login failure from a remote path or permission failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Security practices for scp transfers

  • Protect the private key: keep it on the local computer and never upload it to the VPS.
  • Verify host keys: check a new server’s fingerprint through a trusted console or documented channel.
  • Use key authentication where possible: it avoids putting a password in a command and works with the same SSH authentication used by the login session.
  • Keep secrets out of shell history: do not place passwords, tokens, or other credentials in command arguments.
  • Use the least-privileged destination: stage uploads in a directory the deployment account owns, then perform only the required privileged installation step.
  • Review recursive sources: because -r follows symbolic links encountered during traversal, inspect links before copying a directory tree.

Quick command reference

Task Command
Upload one file scp ./local-file.txt [email protected]:/home/deploy/
Upload with a new name scp ./build/app.tar.gz [email protected]:/tmp/app-release.tar.gz
Download one file scp [email protected]:/var/log/app.log ./logs/
Copy a directory scp -r ./site [email protected]:/var/www/
Use a private key scp -i ~/.ssh/id_ed25519 ./backup.tar.gz [email protected]:/home/deploy/
Use a custom port scp -P 2222 ./backup.tar.gz [email protected]:/home/deploy/
Use a jump host scp -J [email protected] ./local-file [email protected]:/home/deploy/
Show connection diagnostics scp -v ./local-file.txt [email protected]:/home/deploy/

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.