rsh to host and run command as another user
rsh to host and run command as another user
am 09.01.2008 23:10:43 von littlehelphere
I have a script, in which I rsh to a host and run a command based on a
variable. However, I am having issues with this portion of the
script. Would appreciate any ideas.
example
FOOHOME=/usr/local/foo/
I want to rsh to machine b from machine a and run a command as user
foo
from machine a
#rsh -n machineb "su - foo - c '$FOOHOME/bin/command'"
The above does not work and I am wondering how to get this to run.
Re: rsh to host and run command as another user
am 09.01.2008 23:19:15 von littlehelphere
On Jan 9, 5:29 pm, pk
wrote:
> littlehelph...@gmail.com wrote:
> > I have a script, in which I rsh to a host and run a command based on a
> > variable. However, I am having issues with this portion of the
> > script. Would appreciate any ideas.
>
> > example
> > FOOHOME=/usr/local/foo/
> > I want to rsh to machine b from machine a and run a command as user
> > foo
>
> > from machine a
> > #rsh -n machineb "su - foo - c '$FOOHOME/bin/command'"
>
> Can't you just use "-l foo" in the rsh command line?
I need to use a .rsh for this and I would prefer not to for security.
Also, this still wont allow me to expand the variable $FOOHOME
Re: rsh to host and run command as another user
am 09.01.2008 23:29:48 von PK
littlehelphere@gmail.com wrote:
> I have a script, in which I rsh to a host and run a command based on a
> variable. However, I am having issues with this portion of the
> script. Would appreciate any ideas.
>
>
> example
> FOOHOME=/usr/local/foo/
> I want to rsh to machine b from machine a and run a command as user
> foo
>
> from machine a
> #rsh -n machineb "su - foo - c '$FOOHOME/bin/command'"
Can't you just use "-l foo" in the rsh command line?
Re: rsh to host and run command as another user
am 09.01.2008 23:37:30 von PK
littlehelphere@gmail.com wrote:
>> > from machine a
>> > #rsh -n machineb "su - foo - c '$FOOHOME/bin/command'"
>>
>> Can't you just use "-l foo" in the rsh command line?
>
> I need to use a .rsh for this and I would prefer not to for security.
> Also, this still wont allow me to expand the variable $FOOHOME
Ah ok, so /that/ the problem was (it was not clear from your first post).
Well, you put the variable inside single quotes, so it's not expanded.
Re: rsh to host and run command as another user
am 09.01.2008 23:46:49 von Barry Margolin
In article , pk wrote:
> littlehelphere@gmail.com wrote:
>
> >> > from machine a
> >> > #rsh -n machineb "su - foo - c '$FOOHOME/bin/command'"
> >>
> >> Can't you just use "-l foo" in the rsh command line?
> >
> > I need to use a .rsh for this and I would prefer not to for security.
So you want to be asked for their password?
Although there's an rexecd server that implements this (executing a
command line using password authentication rather than .rhosts), I don't
think most Unix systems provide a command like rsh that connects to it.
Can you use ssh rather than rsh? That will allow you to do this, and it
doesn't send the password over the network.
> > Also, this still wont allow me to expand the variable $FOOHOME
>
> Ah ok, so /that/ the problem was (it was not clear from your first post).
> Well, you put the variable inside single quotes, so it's not expanded.
But the single quotes are inside double quotes, should it IS expanded.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Re: rsh to host and run command as another user
am 10.01.2008 00:57:25 von littlehelphere
On Jan 9, 5:46 pm, Barry Margolin wrote:
> In article , pk wrote:
> > littlehelph...@gmail.com wrote:
>
> > >> > from machine a
> > >> > #rsh -n machineb "su - foo - c '$FOOHOME/bin/command'"
>
> > >> Can't you just use "-l foo" in the rsh command line?
>
> > > I need to use a .rsh for this and I would prefer not to for security.
>
> So you want to be asked for their password?
>
> Although there's an rexecd server that implements this (executing a
> command line using password authentication rather than .rhosts), I don't
> think most Unix systems provide a command like rsh that connects to it.
>
> Can you use ssh rather than rsh? That will allow you to do this, and it
> doesn't send the password over the network.
>
> > > Also, this still wont allow me to expand the variable $FOOHOME
>
> > Ah ok, so /that/ the problem was (it was not clear from your first post).
> > Well, you put the variable inside single quotes, so it's not expanded.
>
> But the single quotes are inside double quotes, should it IS expanded.
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***
so for ssh I would need to put the pub key in place, right? Anything
else? Beyond the single quotes is the remainder of the command OK?
Re: rsh to host and run command as another user
am 10.01.2008 09:43:27 von PK
Barry Margolin wrote:
> But the single quotes are inside double quotes, should it IS expanded.
You are correct, my fault. Sorry for overlooking that.
Re: rsh to host and run command as another user
am 10.01.2008 09:46:33 von PK
littlehelphere@gmail.com wrote:
> so for ssh I would need to put the pub key in place, right? Anything
> else? Beyond the single quotes is the remainder of the command OK?
The single quotes are not a problem, as Barry correctly pointed out. With
ssh, and the appropriate keys in place, you could just do
ssh foo@machineb $FOOHOME/bin/command
and you should be OK.