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

Recommended Answers

All 5 Replies

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

for i in $(cat file)
echo "$pass" | scp --stdin source destination

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.

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?

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.

Thanks for the answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.