Comparison and Usage of PSCP and SCP Tools
Differences
PSCP, part of the PuTTY suite, serves as a file transfer utility over SSH for Windows environments, facilitating transfers between Windows and Linux systems.
SCP, conversely, operates exclusively within Linux environments for file transfers between Linux hosts. It lacks resume capability but ensures encrypted data transmission using SSH protocols and identical authentication methods, offering equivalent security. Most Linux distributions include SCP by default.
Usage Examples
PSCP Command Structure
PSCP mirrors SCP functionality but is designed for Windows platforms. To access it globally, place pscp.exe in C:\Windows\System32. Its syntax resembles SCP. Below are essential command formats:
Format One:
pscp [options] [user@]host:source target
Transfers files from remote to local. Parameters include:
user: Remote host usernamehost: Remote IP addresssource: Remote file path (single file only)target: Local destination path and optional filename
Example:
pscp root@192.168.1.245:/root/user.sql ./
Format Two:
pscp [options] source [source...] [user@]host:target
Transfers files from local to remote. Parameters include:
source: Local file(s), separated by spacesuser: Remote host usernamehost: Remote IP addresstarget: Remote destination path
Examples:
pscp -v test.zip root@192.168.1.245:/root/test_rename1.zip
pscp -v test.zip a.zip root@192.168.1.245:/root/
Note: Multiple files cannot specify individual filenames.
Format Three:
pscp [options] -ls [user@]host:filespec
Lists directory contents on remote host.
Example:
pscp -ls root@192.168.1.245:/root/
PSCP Options
-p: Preserves timestamps during file copy-q: Suppresses all messages during transfer-r: Copies entire directories recursively-v: Displays verbose output during transfer-load: Loads saved session settings-P port: Specifies SSH port-l user: Specifies remote username-pw passw: Specifies password for login-1/-2: Forces specific SSH protocol version-4/-6: Forces IPv4 or IPv6 usage-C: Enables compression-i key: Specifies private key file-batch: Disables interactive prompts-unsafe: Allows server-side character replacement (not recommended)
Key parameter explanations:
Port Specification (-P)
pscp -P 2992 test.zip root@192.168.1.245:/root/
Username (-l)
pscp -l root test.zip 192.168.1.245:/root/
Password (-pw)
pscp -l root -pw 123456 test.zip 192.168.1.245:/root/
SCP Command Examples
Local to Remote File Transfer:
scp filename.txt user@host:some/directory
Using Custom Port:
scp -P 2234 filename.txt user@host:some/directory
Multiple Files to Remote:
scp filename1.txt filename2.txt user@host:~
Remote to Local File Transfer:
scp user@host:directory/filename.txt /directory
Remote Directory to Local:
scp -r user@host:directory/folder .
Remote to Remote Transfer:
scp user@host1:directory/filename.txt user@host2:directory