nagios ALL=NOPASSWD: /bin/bash -c /usr/lib/nagios/plugins/check_ide_smart *
This should work and allow arguments.
Could you run
sudo -s
id
And post the output? I want to see if it's actually making you the user you think.
Also, try
sudo cat /etc/sudoers
The output of id here is quite enlightening. When you ran sudo -s
, you were given a UID of 1, while the only UID that the kernel will recognize as having root privileges is UID 0.
Try running
getent passwd | grep ':0:'
and see if any entries have that 0 in their first numeric field, the UID. Whatever account that is is the real superuser on the system, while root
is a fake. Once you know the name, you can try
sudo -s -u username
to get a shell as that user.
You should also post the output of
getent passwd root
The bigger issue here is how such a condition came to pass.
Is this machine offering any network services? If so, someone may have broken into it and taken it over. In that case, you should probably back up the data, do a clean re-install, and audit anything that goes back on it.
If it's more of a personal machine, might there be a knowledgeable prankster who's had access to it recently?
Edit: your comment to another answer suggests that this is a server. I would highly recommend taking it offline ASAP and imaging its disks for forensic purposes. Unless you can identify a benign cause for this in short order, you've probably had your server cracked.
Best Answer
How about combination with "sudo setting in central nagios server" and "Private key authorization"?
Assuming that you are accessing to your dest server by ssh,
Set sudo access with NO Passwd option to nagios user to nagios user in your central nagios server
Generate private and public key with root user and copy the pub key to your destination server.
DO below in root user
ssh-key-gen -t dsa -b 1024 ssh-copy-id -i [path to your .pub file] root@[dest server]
Below is sample result.
[nagios@dev plugins]$ sudo ./check_by_ssh -H localhost -l root "ls -l /proc/2027/exe"; echo $? lrwxrwxrwx. 1 root root 0 Mar 30 19:29 /proc/2027/exe -> /usr/libexec/postfix/master 0