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.
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 :( >you really should convince whomever has made that boneheaded decision that its a lot MORE secure than requiring you to put the password in plaintext scripts> 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 >dunno, never tried. seems to have a nice long man page with lots of examples.
Hi, On Tue, Nov 11, 2008 at 04:42, Fajar Priyanto <fajarpri at arinet.org> wrote:> But, I'm in an environment where PubKeyAuthentication is not allowed in ssh :( > So, I'm confused how to automate it as cronjob.Before you start, consider enabling public keys or requesting that to your sysadmin, since using them is much more secure than storing your passwords in text scripts.> 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?Yes.> Any examples are great help.Google is your friend. http://bash.cyberciti.biz/security/expect-ssh-login-script/ (DISCLAIMER: I haven't tested the script above. Google it yourself if you want to see others.) HTH, Filipe
> 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.Use autoexpect. It will write the expect script for you. I can't think of any reason why this wouldn't work. Barry
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... -Greg