0

My end goal is to create an alias for scp:

First, I need a way of inputting the remote users' password automatically for this to be a single input command. Security isn't a big deal with this, so I' happy to have the password in a text file. I've tried the following, but there all still prompt for input:

scp  from/path usr:w.x.y.z:to/path <<< "passwd"

echo "passwd" | scp  from/path usr:w.x.y.z:to/path

printf "passwd\n" | scp  from/path usr:w.x.y.z:to/path

All still prompt me for input.

Once I've figured that out, I'm going to run:

echo 'alias pts=" fixed command above"' >> ~/.bashrc

Where am I going wrong?

1 Answers1

0

Where you're going wrong is assuming scp reads passwords from standard input - AFAIK it doesn't. You have a number of options:

  1. set up key-based authentication, using a key with an empty passphrase - see How can I set up password-less SSH login?

  2. use the sshpass utility (available from the repository)

  3. script the password interaction using expect
steeldriver
  • 136,215
  • 21
  • 243
  • 336