0

Im trying to scp including password in one line... seems not working.

echo "pass" | scp --stdin source destination

However this does work though

echo "newpass" | passwd --stdin user

same concept, diff result. Any suggestion would be great. Thanks

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by maninaction
0

actually, it does work.. it is just when putting in a for loop then it starts asking for password again.

pass=$1
for i in $(cat file)
do
echo "$pass" | scp --stdin source destination
done
0

uh.. sorry for the confusion but i just figured that if the code is exectued outside the script it works fine.

putting the same code in a script it will prompt for password. scratching my head now.

0

Hi k2k!

Were you able to figure this out? Personally I've found that using keys for authentication is much more reliable (and possibly more secure?) than using passwords in scripting tasks like this. Is that an option in your case?

0

Gromit,
Thanks for your reply but yea, you were absolutely right. I resolved it by using RSA. I actually had done it before, it is just I haven't used linux for a while and I had to kinda learn things again. = )
Thanks and I am all set.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.