Linux – PSCP: Upload an entire folder, Windows to Linux

linuxputtyscpuploadwindows

I am using PSCP to upload some files from Windows to Linux. I can do it fine just uploading one file at a time. But I have some very large directories and I want to upload an entire directory at once.

I have tried:

pscp -i C:\sitedeploy\abt-keypair.ppk includes\* root@mysite.com:/usr/local/tomcat/webapps/ROOT/includes/*

Throws error: "pscp: remote filespec /usr/local/tomcat/webapps/ROOT/includes/*: not a directory"

and

pscp -i C:\sitedeploy\abt-keypair.ppk includes\ root@mysite.com:/usr/local/tomcat/webapps/ROOT/includes/

Throws error: "scp: includes: not a regular file"

and

pscp -i C:\sitedeploy\abt-keypair.ppk includes root@mysite.com:/usr/local/tomcat/webapps/ROOT/includes

Throws error: "scp: includes: not a regular file"

Best Answer

Two problems: First, the * does not go on the destination side. Second, -r is for copying an entire directory and subdirectories.

pscp -i C:\sitedeploy\abt-keypair.ppk includes\* root@mysite.com:/usr/local/tomcat/webapps/ROOT/includes/

Will copy all of the files in the local includes\ directory to the .../includes/ directory on the server.

pscp -r -i C:\sitedeploy\abt-keypair.ppk includes\ root@mysite.com:/usr/local/tomcat/webapps/ROOT/

Will copy the includes\ directory itself, including all files and subdirectories, to the .../ROOT/ directory on the server (where the contents of the local directory would merge with any existing .../ROOT/includes/ directory.

Related Topic