[ale] ssh / sudo file transfer?

Jeff Lightner jlightner at water.com
Wed Dec 5 16:40:16 EST 2007


I'm trying to come up with a command line similar to the tar pipeline
which copies files.   The wrinkle is the user needs to first ssh to the
box as themselves then sudo su to the user name that owns the target
directory.

e.g.  Real user is ralph on server that has the real files.  This ralph
also exists on the target server.   On the target server ralph has
permissions to become oracle user by using "sudo su - oracle" and also
permission to run commands as oracle with "sudo -u oracle <command>".   

We do not have trusts established so users must input his password when
doing an ssh between the servers.   He must also input password when
executing a sudo command on the target server.   This works fine.  

It even works fine when I do something like:
ssh -tt ralph at remotehost "sudo -u oracle sh -c 'ls -l /oracle/prod'" 
Note there is a single quote and a double quote at end of above line.
In this command line it prompts for password for the ssh and then again
for the sudo.

It also works but spits an error if I do a tar pipeline without the sudo
but with the ssh:
tar c dir1 | ssh -tt ralph at remotehost "tar xvf -" 
This copies dir1 and its contents from the source server across to the
home of ralph on remote host.   As noted it works but after the ssh
password has been entered it displays:
tcgetattr: Invalid argument
and then does the transfer successfully.

However, when I attempt to add the "sudo -u" syntax to the pipeline it
spits the same error as above but never really logs in.  It appears that
the sudo is getting the tar information from left side of pipe and
trying to use that for the sudo password.   I've tried various quoting
and parenthetical notation but nothing works.

I'm wondering if anyone has successful pipeline for such file transfers
or some other solution that does not require me to enable ssh trusts for
the user or to setup special sudo commands.   What I'm looking for is
one off transfers not something the user will be doing every day so I
don't want to have to modify sudoers or rsync authorization when they
happen to need to transfer a file in a hurry.
----------------------------------
CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
----------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list