954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

scp specifying password

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

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

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
k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

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.

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

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?

Gromit
Posting Whiz in Training
212 posts since Sep 2008
Reputation Points: 47
Solved Threads: 31
 

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.

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

Thanks for the answer

maninaction
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 1
Solved Threads: 7
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You