# Ask permission questions

**URL:** <https://community.icinga.com/t/ask-permission-questions/3078>\
**Category:** Service Monitoring\
**Created:** [December 19, 2019, 6:48am UTC](https://community.icinga.com/t/ask-permission-questions/3078 "2019-12-19T06:48:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jqrun](https://community.icinga.com/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@jqrun](https://community.icinga.com/u/jqrun)\
**Post date:** [December 19, 2019, 6:48am UTC](https://community.icinga.com/t/ask-permission-questions/3078/1 "2019-12-19T06:48:52Z")

</div>

If my script doesn’t add sudo  
cat: /var/log/kern.log: Permission denied  
If my script adds sudo  
sudo: no tty present and no askpass program specified

Is there any good way

---

<div class="post-metadata">

**Author:** ![aflatto](https://community.icinga.com/user_avatar/community.icinga.com/aflatto/32/160_2.png) [@aflatto](https://community.icinga.com/u/aflatto)\
**Post date:** [December 19, 2019, 7:23am UTC](https://community.icinga.com/t/ask-permission-questions/3078/2 "2019-12-19T07:23:09Z")

</div>

Perhaps use a non interactive sudo :

-n, --non-interactive  
Avoid prompting the user for input of any kind. If a password is required for the command to run,  
sudo will display an error message and exit.

---

<div class="post-metadata">

**Author:** ![jqrun](https://community.icinga.com/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@jqrun](https://community.icinga.com/u/jqrun)\
**Post date:** [December 19, 2019, 8:03am UTC](https://community.icinga.com/t/ask-permission-questions/3078/3 "2019-12-19T08:03:09Z")

</div>

icinga2 Is the user executing the script nagois?

---

<div class="post-metadata">

**Author:** ![jqrun](https://community.icinga.com/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@jqrun](https://community.icinga.com/u/jqrun)\
**Post date:** [December 19, 2019, 9:07am UTC](https://community.icinga.com/t/ask-permission-questions/3078/4 "2019-12-19T09:07:06Z")

</div>

sudo -n  
prompt：  
sudo: a password is required

---

<div class="post-metadata">

**Author:** ![homerjay](https://community.icinga.com/user_avatar/community.icinga.com/homerjay/32/377_2.png) [@homerjay](https://community.icinga.com/u/homerjay)\
**Post date:** [December 19, 2019, 9:19am UTC](https://community.icinga.com/t/ask-permission-questions/3078/5 "2019-12-19T09:19:12Z")

</div>

That depends on the system which executes the script.

e.g:  
Ubuntu: nagios  
CentOS: icinga  
(possibly generalized: debian-based: nagios, redhat-based: icinga)

You can try to execute the script on the target/executing system, e.g.:

```
sudo -u nagios /path/to/script
sudo -u icinga /path/to/script

```

Additional note:  
Both users do not have a login-shell.

Or you simply look whether the user nagios or icinga exist on the target system.

---

<div class="post-metadata">

**Author:** ![homerjay](https://community.icinga.com/user_avatar/community.icinga.com/homerjay/32/377_2.png) [@homerjay](https://community.icinga.com/u/homerjay)\
**Post date:** [December 19, 2019, 9:20am UTC](https://community.icinga.com/t/ask-permission-questions/3078/6 "2019-12-19T09:20:05Z")

</div>

You need to add the sudo-rights for the specific user

---

<div class="post-metadata">

**Author:** ![jqrun](https://community.icinga.com/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@jqrun](https://community.icinga.com/u/jqrun)\
**Post date:** [December 19, 2019, 9:31am UTC](https://community.icinga.com/t/ask-permission-questions/3078/7 "2019-12-19T09:31:38Z")

</div>

I tested with sudo permissions added

nagios ALL=(ALL) NOPASSWD:ALL # That does not work

nagios ALL = NOPASSWD:ALL # this is ok
