Wednesday, June 02, 2010

“PSCP”- Putty Secure Copy

Step 1: Download PSCP client.

Step 2: Create a folder in your Windows drive C root directory named ssh.

Step 3: Copy and paste pscp.exe into this folder. The Windows path of this executable file should be (after folder creation and moving pscp.exe to the ssh folder):

C:\ssh>pscp.exe
PuTTY Secure Copy client
Release 0.60
Usage: pscp [options] [user@]host:source target
pscp [options] source [source...] [user@]host:target
pscp [options] -ls [user@]host:filespec
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-p preserve file attributes
-q quiet, don't show statistics
-r copy directories recursively
-v show verbose messages
-load sessname Load settings from saved session
-P port connect to specified port
-l user connect with specified username
-pw passw login with specified password
-1 -2 force use of particular SSH protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-batch disable all interactive prompts
-unsafe allow server-side wildcards (DANGEROUS)
-sftp force use of SFTP protocol
-scp force use of SCP protocol


C:ssh>pscp -P 22 codexm@php-developer.org:html/robots.txt c:downloads

codexm@php-developer.org's password:

robots.txt | 1 kB | 1.1 kB/s | ETA: 00:00:00 | 100%

C:ssh>

You can decide to use any Windows folder for where you need to download your files. “-P 22" means you connect to Port 22, which is the default SSH port. Html/robots.txt is the path where the file is located. This is where browsing/file navigation techniques using SSH (discussed previously) will help you to know the file location/path.

Step 6: To upload one file (e.g testfile.txt) to your website's root directory from your Windows local computer (e.g. located in C:uploads):

Putty command line example:

C:ssh>pscp -P 22 c:uploadstestfile.txt codexm@php-developer.org:html/

codexm@php-developer.org's password:

testfile.txt | 0 kB | 0.0 kB/s | ETA: 00:00:00 | 100%

C:ssh>

The root directory is signified by the path: html/

SSH sessions using pscp will be automatically closed after completing the transfer.

C:\ssh>pscp -scp codexm@php-developer.org:html/robots.txt .

http://www.codewalkers.com/c/a/Miscellaneous/Putty-File-Transfer-Commands-in-SSH-Protocol/2/

~~~~~~~~~~~~~~~~~~~~~~~~

warning: remote host tried to write to a file called 'robots.txt'
when we requested a file called 'rob*.txt'.
If this is a wildcard, consider upgrading to SSH-2 or using
the '-unsafe' option. Renaming of this file has been disallowed.

C:\ssh>pscp -scp -unsafe codexm@php-developer.org:html/rob*.txt .