rsync/ssh passwords

John Chambers jc at trillian.mit.edu
Sun Mar 28 11:34:01 EST 2004


Since we're contemplating getting back to techie topics, I  have  one
that's been annoying me for a while.

I've been using rsync to backup/mirror files on several machines.   I
usually  call  rsync from any of several scripts, which does the same
command with different hostnames.  I use ssh

The problem is that, after it's churned for a while copying files  to
or  from host1, it proceeds to host2, which then asks for a password.
Usually I'm looking at some other  window  at  the  time,  and  don't
notice  for a while that the rsync window wants another password.  By
the time I notice it, host2 has already times out the  operation.   I
don't  see  any clue of this, of course, so I type the password - and
get an error message. That part of the rsyc process has now bombed.

The obvious thing is to have the script know the passwords.  But this
doesn't work It seems that ssh does an end run around the script, and
talks directly to /dev/tty  to  get  the  password.   The  script  is
sleeping,  of  course,  waiting on the rsync command, and has no idea
that this is happening.

The ssh docs don't seem to mention this at all. Is there any kown way
to get ssh to play nice and accept a password from a parent process?

If all else fails, I suppose I can pull out  expect  and  use  it  to
defeat this misuse of /dev/tty. That is one of the things that expect
was invented for. But this is sorta like swatting flies with a sledge
hammer.  It would be nicer if there were some simple, elegant way for
my scripts to tell rsync "Use this password: ..."

If nobody knows, I'll just use expect.




More information about the Discuss mailing list