Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command to automatically input password for pscp

Tags:

I want to copy some file to a remote Linux system from my Windows PC using pscp (from putty). I wrote a small script that call the pscp commands in this way:

"C:\Users\hp\Desktop\pscp.exe" -scp C:\Users\hp\Desktop\scripts\* [email protected]:/root/scripts "C:\Users\hp\Desktop\pscp.exe" -scp C:\Users\hp\Desktop\scripts2\* [email protected]:/root/scripts2   pause 

But when I launch this bat script, I'm asked to input the password, so I input the password manually.

Is there a way to input the password automatically through the batch file?

like image 765
MOHAMED Avatar asked Apr 15 '14 09:04

MOHAMED


People also ask

Can we pass password in scp command?

The SCP command; on its own, is not sufficient enough to accommodate password authentication under a one-line command usage and therefore leads to a successive password prompt for the OS user to enter the required login passcode.


2 Answers

pscp -pw yourPasswordHere C:\Users\testUser\Downloads\test.sh [email protected]:/home/testUser 

I've noticed that no one posted sample of that command with -pw option.

like image 55
blueberry0xff Avatar answered Sep 23 '22 17:09

blueberry0xff


From putty documentation

5.2.2.6 -pw passw login with specified password

If a password is required to connect to the host, PSCP will interactively prompt you for it. However, this may not always be appropriate. If you are running PSCP as part of some automated job, it will not be possible to enter a password by hand. The -pw option to PSCP lets you specify the password to use on the command line.

like image 25
MC ND Avatar answered Sep 21 '22 17:09

MC ND