PSCP – PuTTY Secure Copy for Windows

PSCP (pscp.exe) is the command-line secure copy tool in the PuTTY suite for Windows. It transfers files between a Windows machine and Linux or Unix servers over an SSH-encrypted connection — using the same authentication method as PuTTY SSH sessions, including keys managed by Pageant. PSCP putty syntax is compatible with standard SCP clients.

Download PSCP

PSCP is available as a standalone executable from the official PuTTY release page:

chiark.greenend.org.uk – pscp.exe standalone download

Basic PSCP Syntax

pscp [options] source destination

# Uploading (Windows → Server):
pscp [options] local-file user@host:remote-path

# Downloading (Server → Windows):
pscp [options] user@host:remote-file local-path

Common Command-Line Switches

SwitchDescription
-P portConnect on a non-standard SSH port.
-i key.ppkUse a specific PPK private key file for authentication.
-rRecursive copy — transfer entire directory trees.
-pPreserve file timestamps and permissions from the source.
-qQuiet mode — suppress progress meter output.
-batchNon-interactive: abort rather than prompt for passwords or host keys.
-scpForce use of SCP protocol (vs. SFTP).
-sftpForce use of SFTP protocol (more reliable for large/complex transfers).
-pw passwordPassword authentication (insecure — prefer key-based auth).
-agentUse keys from a running Pageant agent.
-hostkey fingerprintAccept a specific host key fingerprint (for scripting).

Upload a File to a Remote Server

# Upload a single file
pscp -i "C:keysserver.ppk" report.pdf admin@192.168.1.10:/home/admin/reports/

# Upload with key from Pageant (no -i needed if Pageant is running)
pscp report.pdf admin@192.168.1.10:/home/admin/reports/

# Upload to a specific non-default SSH port
pscp -P 2222 -i "C:keysserver.ppk" config.yaml user@example.com:/etc/app/

Download a File from a Remote Server

# Download a single file to current directory
pscp admin@192.168.1.10:/var/log/app.log .

# Download to a specific local path
pscp admin@192.168.1.10:/var/log/app.log "C:Logsapp.log"

# Download and preserve timestamps
pscp -p admin@192.168.1.10:/var/www/backup.tar.gz "D:Backups"

Recursive Directory Transfer

# Upload entire directory to remote server
pscp -r "C:Deployapp" user@example.com:/var/www/app/

# Download entire remote directory
pscp -r user@example.com:/var/www/app/ "C:LocalBackupapp"

Automated File Transfer in Batch Scripts

Use -batch to prevent the script from hanging on interactive prompts. Pre-accept the host key by connecting with PuTTY first, or use -hostkey to specify it:

@echo off
:: Automated backup script
pscp -batch -i "C:keysackup.ppk" ^
  user@backup.example.com:/var/backups/db_dump.sql ^
  "D:Backupsdb_dump_%DATE:~-4,4%%DATE:~-10,2%%DATE:~-7,2%.sql"

if %ERRORLEVEL% NEQ 0 (
    echo ERROR: Backup download failed >> backup.log
    exit /b 1
)
echo Backup successful >> backup.log

Using Wildcards to Transfer Multiple Files

# Download all .log files from a remote directory
pscp admin@example.com:"/var/log/*.log" "C:Logs"

# Note: When using wildcards, quote the remote path to prevent local shell expansion
# Wildcards are evaluated on the remote server by the SCP/SFTP subsystem

PSCP vs. PSFTP

ToolProtocolBest For
pscp.exeSCP / SFTPSingle file transfers, batch scripts, automation pipelines.
psftp.exeSFTPInteractive file management, browsing directories, resuming transfers.
Tip: For scripted automation, PSCP is preferable because it exits with a status code that batch scripts and CI pipelines can check. Use PSFTP for interactive sessions where you need to navigate and manage remote directories.

Security Best Practices

  • Always use key-based authentication (-i key.ppk or Pageant) instead of -pw.
  • Use -batch in automated scripts to prevent hanging on unexpected prompts.
  • Restrict the SSH user account on the server to only the directories it needs access to.
  • Consider using chroot jails or ForceCommand in sshd_config to limit server-side access for automated file transfer accounts.