Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to copy from remote box with scp, while the fact that each time I have to re-enter password is annoying. So I store my password in plain text and expect the following code should work

scp -Pport_num username@hostname:path_to_file local_path < passwd

After googling, I know this target can be achieved with the help of expect but I can't figure out why input redirection will fail.

Thanks and best regards.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

scp isn't looking for anything from standard input, so passing your password this way won't help. Yes, expect can be used in a case like this, but you'd be better off authenticating via public key -- either with a specific password-less public/private keypair, or using an ssh agent in your current session.

So many tutorials out there, including: this one

share|improve this answer
    
Thanks for your fast response. "scp isn't looking for anything from standard input". Then where does our input go? And where will scp look for input? Thank you again. –  Summer_More_More_Tea Jun 21 '12 at 6:03
1  
Your redirected file just goes into the "bit bucket", to nowhere, much as it would with the command echo "Hello" < passwd. scp (or ssh) will ask for password if necessary, but do not take that from stdin. ssh will send stdin to the command on the remote machine; I don't think scp uses stdin at all. –  Lars Rohrbach Jun 21 '12 at 6:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.