sudo and ssh

John231

New Member
Joined
Jul 23, 2018
Messages
1
Reaction score
0
Credits
0
Hello.

If somebody can help me please, i am a complet newbie:


I have no access to root in two servers, netihter 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
operador@es2petvid01v:~/.ssh$

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

or

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
frown.gif
 


Hello John,
and welcome to Linux.org

Which OS you run?

instead try this:
ssh operator@server1 /usr/bin/bash -s | sudo su - sauron /etc/init.d/romillot status

It should open an bash und server1 and input everything after the pipe to this bash.

Greetings

Scoobithepirate
 

Members online


Latest posts

Top