Author Topic: sudo within ssh remote  (Read 334 times)

0 Members and 1 Guest are viewing this topic.

Offline John231

  • Jr. Member
  • **
  • Posts: 1
  • Karma: 0
  • I've just joined!
    • View Profile
    • Awards
sudo within ssh remote
« on: July 23, 2018, 07:06:33 am »
Hello

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

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
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

Online Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 17681
  • Karma: 457
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: sudo within ssh remote
« Reply #1 on: July 23, 2018, 03:30:33 pm »
Maybe try
Code: [Select]
ssh operador@server1 "/bin/bash -c 'sudo su - sauron /etc/init.d/romillot status'"
WARNING: You are logged into reality as 'root'
logging in as 'insane' is the only safe option.
pcnetspec.co.uk

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal