How to pass password to scp?
You can script it with a tool like expect (there are handy bindings too, like Pexpect for Python).
Complete password field scp command on linux
You can generate a pair of RSA/DSA keys (public and private). In your terminal:
$ ssh-keygen
It will generate a pair of files:
- Private key:
.ssh/id_dsa
- Public key:
.ssh/id_dsa.pub
Then, if you have access to remote host, you can add your public key to .ssh/authorized_keys
file. In your remote host, copy the public key and use the following command:
cat id_dsa.pub >> .ssh/authorized_keys
scp command asks for a password
You are using sudo
, which switches to the root user for the command, so the credentials installed in root's ssh configuration are used.
How to respond to password prompt when using SCP in a shell script?
Are ssh keys not allowed? That would be a better solution.
Force SCP not to prompt for password
Typically:
scp -o BatchMode=yes ..
Command to automatically input password for pscp
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.
Related Topics
Run Meteor as a Daemon Process
Why Does Printf Still Work with Rax Lower Than The Number of Fp Args in Xmm Registers
Awk: Sum Up Column Values Across Multiple Files with Identical Column Layout
Shell Exclamation Mark Command
Chef-Server Stuck Ruby_Block[Supervise_Rabbitmq_Sleep] Action Run on Docker Container
Phony Targets for Parallel Execution of Make
Brother Ql-720Nw Specifying Media Size Seems Ignored
Valueerror: Namespace Gtk Not Available
Bash Script Commands Not Working in Cron
Cvs Error: Failed to Create Lock Directory... Permission Denied
Would Gcc 4.8 and 4.7 Peacefully Coexist on The Same Machine
Extract/See Content of a Specific File Inside a .War File
Sublimetext3 Build on The Server Over Ssh