Discussion:
rsync + switching user after connection
Darragh Bailey
2004-11-16 22:19:32 UTC
Permalink
Trying to use rsync to update a local copy of a website from the one sitting on
a server.

Normally I can use

rsync -vare ssh ***@host:src_dir/* local_dir/ --exclude-from=local_dir/EXCL

But in this case I need to be able to switch user after login in order to
retreive the files fully due to permissions, before any one askes its not root,
but a common website editing account shared between a few members. Additionally
loging in remotely as the shared user will not work either.


I was looking at
rsync -var --rsh="ssh -l user host su - new_user" :src_dir/* local_dir/
--exclude-from=local_dir/EXCL

But rsync terminates the connection. Is it possible to do it this way, in which
case could someone point out what I'm missing or do I have to resort to a script
in order to be able to perform this?


output from rsync is

bash: su - new_user: command not found
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(342)


experimenting from the command line with just ssh gets the message
su: must be run from a terminal

So that suggests what the problem rsync is having but isn't any assistance in
building a new command line that would work.

Setting up a script on the far side to run when I login is no good since I
sometimes need to be able to ssh in without becoming a different user
afterwards.

Additionally taring and bziping the website up and downloading it is not really
an option. Once in a while that can be done, the rest of the time I need to be
able to use either rsync over ssh or some other system than only retreives
modified files over ssh.

--
Darragh

"Nothing's foolproof to a sufficently talented fool"
--
Irish Linux Users' Group
http://www.linux.ie/mailman/listinfo/ilug/
Kieran.Tully AT acm.org
2004-11-16 23:12:30 UTC
Permalink
On Tue, 16 Nov 2004 22:19:32 +0000, Darragh Bailey
Post by Darragh Bailey
Trying to use rsync to update a local copy of a website from the one sitting on
a server.
But in this case I need to be able to switch user after login in order to
retreive the files fully
loging in remotely as the shared user will not work either.
I was looking at
rsync -var --rsh="ssh -l user host su - new_user" :src_dir/* local_dir/
--exclude-from=local_dir/EXCL
But rsync terminates the connection. Is it possible to do it this way, in which
case could someone point out what I'm missing or do I have to resort to a script
in order to be able to perform this?
A work-around might be for newuser to clone rsync
somewhere only accessible to user, chmod u+s, then
invoke rsync with --rsync_path=/path/to/setuid/bin/

A better solution would be to set the groups up
"properly" so user can r/w newuser's web files,
but I'm guessing you don't have that option!

I'm also assuming some of your web files are
scripts, so wget is not an option...
--
Kieran Tully, Software Developer and Tenor
Reply to Kieran.Tully AT acm.org
http://kieran.tul.ly http://www.cs.tcd.ie/~tullyka
--
Irish Linux Users' Group
http://www.linux.ie/mailman/listinfo/ilug/
Barry O'Donovan
2004-11-16 23:22:56 UTC
Permalink
Post by Darragh Bailey
Trying to use rsync to update a local copy of a website from the one
sitting on a server.
Normally I can use
--exclude-from=local_dir/EXCL
But in this case I need to be able to switch user after login in
order to retreive the files fully due to permissions,
Can you set up a common group with read access?

On one of the servers I admin, multiple users require write access to
the web pages and I use a "webedit" group for this.

e.g.
-rw-rw-r-- 1 apache webedit 415 Jul 17 20:25 index.php

Regards,
Barry
Post by Darragh Bailey
before any one
askes its not root, but a common website editing account shared
between a few members. Additionally loging in remotely as the shared
user will not work either.
I was looking at
rsync -var --rsh="ssh -l user host su - new_user" :src_dir/*
local_dir/ --exclude-from=local_dir/EXCL
But rsync terminates the connection. Is it possible to do it this
way, in which case could someone point out what I'm missing or do I
have to resort to a script in order to be able to perform this?
output from rsync is
bash: su - new_user: command not found
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at
io.c(342)
experimenting from the command line with just ssh gets the message
su: must be run from a terminal
So that suggests what the problem rsync is having but isn't any
assistance in building a new command line that would work.
Setting up a script on the far side to run when I login is no good
since I sometimes need to be able to ssh in without becoming a
different user afterwards.
Additionally taring and bziping the website up and downloading it is
not really an option. Once in a while that can be done, the rest of
the time I need to be able to use either rsync over ssh or some other
system than only retreives modified files over ssh.
--
Darragh
"Nothing's foolproof to a sufficently talented fool"
--
Regards,
Barry O'Donovan
http://www.barryodonovan.com/
http://www.ihl.ucd.ie/

Public key: http://www.barryodonovan.com/gpg.asc
--
Irish Linux Users' Group
http://www.linux.ie/mailman/listinfo/ilug/
Michael Conry
2004-11-17 00:09:29 UTC
Permalink
On Tue, 16 Nov 2004 22:19:32 +0000, Darragh Bailey
Post by Darragh Bailey
Trying to use rsync to update a local copy of a website from the one sitting on
a server.
Normally I can use
But in this case I need to be able to switch user after login in order to
retreive the files fully due to permissions, before any one askes its not root,
but a common website editing account shared between a few members. Additionally
loging in remotely as the shared user will not work either.
Could you do something like the following: ssh to the remote server to
run the rsync process through sudo (sudo being configured so you can
switch to whatever user is required on the remote host). Or maybe you
could put the required rsync commands (again written so that they are
run on the _remote_ host) in a script on the remote server and make it
suid whatever username is required (but executable only by your own
user account for some security).

The other suggestions (already posted on list by others) regarding
groups/proper-permissions are far better solutions, but it all depends
on what is possible.

michael
--
Irish Linux Users' Group
http://www.linux.ie/mailman/listinfo/ilug/
Loading...