Do-Over a mangled sudo password?

Paul Lussier p.lussier at comcast.net
Fri Feb 3 19:39:01 EST 2006


Ted Roche <tedroche at tedroche.com> writes:

> Simple question, I expect, but haven't been able to locate the answer.

Others have already provided working answers, so I won't bother
reiterating :)

> I'm working in an environment where I have to sudo a number of
> commands when logged into a remote machine via ssh.

Have you thought of a different approach?  I don't know what your
limitations are wrt sudo use (i.e., are you using it for it's
logging/safety, or has it been imposed upon you by your sysadmin?)

Assuming you can do anything you want, you just need to provide a
password, one obvious thing is to 'sudo su', then run the commands you
need.

Another obvious thing, provided you have the capability, is to ssh
directly to the remote machine as root, completely by-passing sudo.

A not-so-obvious thing, but one which might invoke a 'Duh!' would be
to wrap up your commands into a shell script, then run the single
shell script under sudo.

A nother not-so-obvious thing would be to use ssh-key-based commands.
Set up key entries in root's authorized_keys file (or your own for
that matter if you need to do things as root) which are limited to
certain commands.  This is *really* useful if you need to allow a
certain person to ssh into a box to execute a very limited set of
commands as root.  Set up different keys for different commands, then
when ssh'ing, you can specify which key to use, which in turn dictates
which command to run on the remote side.

Of course, all these things require that you have a little flexibility
with your sudo/ssh environment.
-- 

Seeya,
Paul



More information about the gnhlug-discuss mailing list