Complete Password Field Scp Command on Linux

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



Leave a reply



Submit