LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash: auto input password how to ? (https://www.linuxquestions.org/questions/linux-newbie-8/bash-auto-input-password-how-to-828981/)

phyyu 08-28-2010 05:43 AM

Bash: auto input password how to ?
 
Hi guys,
When I use the scp command, here is a command prompt "Input password:",
Now I want to use a one line command to perform the scp command.
I tested the "echo "password" | scp xxx yu@10.xxx.xxx.xxx:/", but failed.
Thanks in advance.
Yu

smoker 08-28-2010 05:55 AM

You really need to set up public key authentication so that you can use the -i <identity_file> command line switch. You could also try the -B switch but I don't think that will work unless the password is supplied at least once to begin with.

man scp

druuna 08-28-2010 06:01 AM

Hi,

Both scp and ssh (both are handled by the same daemon: sshd) will not allow and do not have an options to give the password on the command line or in a script.

The only solution available is creating password-less ssh/scp.

Here are 2 articles that describes how:
Pass on Passwords with scp
HowTo SSH/SCP without a password

There are a lot more articles (and even on LQ there are many threads dealing with this). Use your search engine to look for other ones if the 2 provided aren't sufficient.

Hope this helps.


All times are GMT -5. The time now is 08:05 PM.