# Having Sensu sudo

**URL:** https://discourse.sensu.io/t/having-sensu-sudo/26
**Category:** Sensu Classic (EOL)
**Created:** [May 16, 2013, 10:23pm UTC](https://discourse.sensu.io/t/having-sensu-sudo/26 "2013-05-16T22:23:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Armstron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/christopher_armstron/32/398_2.png) [@Christopher\_Armstron](https://discourse.sensu.io/u/Christopher_Armstron)
#### Post date: [May 16, 2013, 10:23pm UTC](https://discourse.sensu.io/t/having-sensu-sudo/26/1 "2013-05-16T22:23:21Z")

</div>

Hello folks,

I am trying to have sensu run checks as another user. So, in the check body, I am doing **/usr/bin/sudo -u postgres /path/to/our/sql/check**. However, this results in an error:

**sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts**

It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?

Thanks,

Chris

---

<div class="post-metadata">

### Author: ![Sean\_Porter](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Sean\_Porter](https://discourse.sensu.io/u/Sean_Porter)
#### Post date: [May 16, 2013, 10:27pm UTC](https://discourse.sensu.io/t/having-sensu-sudo/26/2 "2013-05-16T22:27:14Z")

</div>

The Sensu user will need passwordless sudo. You may use a /etc/sudoers.d/ file for granular\* control.

> **···**
>
> On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong [chris@chrisarmstrong.me](mailto:chris@chrisarmstrong.me) wrote:
> 
> > Hello folks,
> 
> > I am trying to have sensu run checks as another user. So, in the check body, I am doing **/usr/bin/sudo -u postgres /path/to/our/sql/check**. However, this results in an error:
> 
> > 
> 
> > **sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts**
> 
> > 
> 
> > It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?
> 
> > 
> 
> > Thanks,
> 
> > Chris
> 
> –  
> Cheers,
> 
> Sean Porter
> 
> { blog: “[http://portertech.ca](http://portertech.ca/)”, projects: “[https://github.com/portertech](https://github.com/portertech)” }

---

<div class="post-metadata">

### Author: ![Christopher\_Armstron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/christopher_armstron/32/398_2.png) [@Christopher\_Armstron](https://discourse.sensu.io/u/Christopher_Armstron)
#### Post date: [May 16, 2013, 10:30pm UTC](https://discourse.sensu.io/t/having-sensu-sudo/26/3 "2013-05-16T22:30:49Z")

</div>

Thanks Sean! Is the way I am using sudo in the check the recommended sensu way? Or is there a way to tell sensu it should sudo to run a check? I assume by default it just runs as the normal user?

> **···**
>
> On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong [chris@chrisarmstrong.me](mailto:chris@chrisarmstrong.me) wrote:
> 
> > Hello folks,
> 
> > I am trying to have sensu run checks as another user. So, in the check body, I am doing **/usr/bin/sudo -u postgres /path/to/our/sql/check**. However, this results in an error:
> 
> > 
> 
> > **sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts**
> 
> > 
> 
> > It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?
> 
> > 
> 
> > Thanks,
> 
> > Chris
> 
> Cheers,
> 
> Sean Porter
> 
> { blog: “[http://portertech.ca](http://portertech.ca/)”, projects: “[https://github.com/portertech](https://github.com/portertech)” }
> 
> –

---

<div class="post-metadata">

### Author: ![Joe\_Miller](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/joe_miller/32/160_2.png) [@Joe\_Miller](https://discourse.sensu.io/u/Joe_Miller)
#### Post date: [May 16, 2013, 10:48pm UTC](https://discourse.sensu.io/t/having-sensu-sudo/26/4 "2013-05-16T22:48:09Z")

</div>

example setup:

/etc/sudoers.d/sensu:

Defaults:sensu !requiretty

Defaults:sensu secure\_path = /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

sensu ALL = NOPASSWD: /etc/sensu/plugins/check-ping-private-gateway.rb

> **···**
>
> On Thu, May 16, 2013 at 3:30 PM, Christopher Armstrong [chris@chrisarmstrong.me](mailto:chris@chrisarmstrong.me) wrote:
> 
> > Thanks Sean! Is the way I am using sudo in the check the recommended sensu way? Or is there a way to tell sensu it should sudo to run a check? I assume by default it just runs as the normal user?
> > 
> > On Thu, May 16, 2013 at 3:27 PM, Sean Porter [portertech@gmail.com](mailto:portertech@gmail.com) wrote:
> > 
> > > The Sensu user will need passwordless sudo. You may use a /etc/sudoers.d/ file for granular\* control.
> 
> > 
> 
> On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong [chris@chrisarmstrong.me](mailto:chris@chrisarmstrong.me) wrote:
> 
> > Hello folks,
> 
> > I am trying to have sensu run checks as another user. So, in the check body, I am doing **/usr/bin/sudo -u postgres /path/to/our/sql/check**. However, this results in an error:
> 
> > 
> 
> > **sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts**
> 
> > 
> 
> > It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?
> 
> > 
> 
> > Thanks,
> 
> > Chris
> 
> Cheers,
> 
> Sean Porter
> 
> { blog: “[http://portertech.ca](http://portertech.ca/)”, projects: “[https://github.com/portertech](https://github.com/portertech)” }
> 
> –

---

<div class="post-metadata">

### Author: ![Christopher\_Armstron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/christopher_armstron/32/398_2.png) [@Christopher\_Armstron](https://discourse.sensu.io/u/Christopher_Armstron)
#### Post date: [May 16, 2013, 11:19pm UTC](https://discourse.sensu.io/t/having-sensu-sudo/26/5 "2013-05-16T23:19:21Z")

</div>

Thanks Joe - I’ll be sure to add the “requiretty” part.

> **···**
>
> On Thu, May 16, 2013 at 3:30 PM, Christopher Armstrong [chris@chrisarmstrong.me](mailto:chris@chrisarmstrong.me) wrote:
> 
> > Thanks Sean! Is the way I am using sudo in the check the recommended sensu way? Or is there a way to tell sensu it should sudo to run a check? I assume by default it just runs as the normal user?
> > 
> > On Thu, May 16, 2013 at 3:27 PM, Sean Porter [portertech@gmail.com](mailto:portertech@gmail.com) wrote:
> > 
> > > The Sensu user will need passwordless sudo. You may use a /etc/sudoers.d/ file for granular\* control.
> 
> > 
> 
> On Thu, May 16, 2013 at 3:23 PM, Christopher Armstrong [chris@chrisarmstrong.me](mailto:chris@chrisarmstrong.me) wrote:
> 
> > Hello folks,
> 
> > I am trying to have sensu run checks as another user. So, in the check body, I am doing **/usr/bin/sudo -u postgres /path/to/our/sql/check**. However, this results in an error:
> 
> > 
> 
> > **sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: no tty present and no askpass program specified Sorry, try again. sudo: 3 incorrect password attempts**
> 
> > 
> 
> > It seems like this is a common use-case, so there must be something I am missing. I assume sensu runs checks as its own user account. So, how do we have it run checks as root or as another user?
> 
> > 
> 
> > Thanks,
> 
> > Chris
> 
> Cheers,
> 
> Sean Porter
> 
> { blog: “[http://portertech.ca](http://portertech.ca/)”, projects: “[https://github.com/portertech](https://github.com/portertech)” }
> 
> –

---

<div class="post-metadata">

### Author: ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)
#### Post date: [November 22, 2018, 2:04am UTC](https://discourse.sensu.io/t/having-sensu-sudo/26/6 "2018-11-22T02:04:52Z")

</div>


