[CentOS] Can expect do this?

Greg Bailey gbailey at lxpro.com
Tue Nov 11 18:31:19 UTC 2008

Fajar Priyanto wrote:
> Hi all,
> I'm trying to scp some files from machine1 to machine2.
> But, I'm in an environment where PubKeyAuthentication is not allowed in ssh :(
> So, I'm confused how to automate it as cronjob.
> However, I read somewhere that we can write a little bash script that
> will utilize 'expect' to answer for the ssh password prompt?
> Can we do this?
> Any examples are great help.
> Thank you.

I would concur with everyone else who says you really should be using 
public keys for this sort of thing.  But, another option, if you're 
really forced to use it, is to set the SSH_ASKPASS environment variable 
to a program that spits out the password, and then ssh will use that for 
the password instead of prompting the user for it.  (See 'ssh' man page)...

Definitely not recommended, for all the reasons stated in replies to 
this thread...


More information about the CentOS mailing list