sudo within ssh remote


If somebody can help me plese. I am a complete newbie :frowning:

I have 2 servers…

I have no access to root, nor to sudoers file in any server.

I have a server that is named server1 (the server). And i have another server2 (the client)

In server1 i log in with user operador (it’s the only password i have), and i have permission to do:

(root) NOPASSWD: /bin/su - sauron

So i do : sudo su - sauron , and then when i do: sudo -l , i get:

User sauron may run the following commands on this host:
(root) NOPASSWD: /etc/init.d/tomcat
(root) NOPASSWD: /etc/init.d/romillot

So i do : sudo /etc/init.d/romillot [stop/start/status]

In server2 i have only the password for operador.

I have configured the remote ssh without passwrod, so i am able to do :

operador@server2:~/.ssh$ ssh operador@server1 “uname -a”
Linux server1 2.6.39-300.17.2.el6uek.x86_64 #1 SMP Wed Nov 7 17:48:36 PST 2012 x86_64 x86_64 x86_64 GNU/Linux

And now I am trying to remotely restart the romillot service (using the ssh without password). So I try to do something like:

ssh operator@server1 “sudo su - sauron /etc/init.d/romillot status”

But at first i get:
sudo: sorry, you must have a tty to run sudo

I try other things:

operador@server2:~/.ssh$ ssh operador@server1 “/bin/bash sudo su - sauron /etc/init.d/romillot status”
/bin/bash: sudo: No such file or directory


operador@server2:~/.ssh$ ssh operador@server1 “/bin/bash /usr/bin/sudo su - sauron /etc/init.d/romillot status”
/bin/bash: /usr/bin/sudo: Permission denied

As i said , i am a complete newbie

Maybe try

ssh operador@server1 "/bin/bash -c 'sudo su - sauron /etc/init.d/romillot status'"