[CentOS] echo password into bash script

Peter peter at pajamian.dhs.org
Tue Aug 25 20:04:27 UTC 2015


On 08/26/2015 04:51 AM, Tim Dunphy wrote:
> Hey guys,
> 
>  I'm trying to echo my password into some commands inside of a bash script.
> But I think I'm going about it incorrectly.
> 
> Here's the top part of my script:
> 
> #!/bin/bash
> pub="~/.ssh/id_rsa.pub"
> dps_pass="my_pass"
> ssh="/usr/bin/ssh"
> scp="/usr/bin/scp"
> for i in 10.10.10.2{5,6}
> do
> echo "xfring key up"
> echo $dps_pass |  $scp $PUB  digitalplatform@$i:

Don't try to automate your password like this for scp or other
ssh-related apps.  Generate and use a public/private keypair instead and
your script will then be able to connect without prompting for a password.


Peter



More information about the CentOS mailing list