# Kitchen verify causes "sudo failed and requires TTY" when trying to use inspec

**URL:** <https://discourse.chef.io/t/kitchen-verify-causes-sudo-failed-and-requires-tty-when-trying-to-use-inspec/8632>\
**Category:** Chef Infra (archive)\
**Created:** [June 6, 2016, 7:11pm UTC](https://discourse.chef.io/t/kitchen-verify-causes-sudo-failed-and-requires-tty-when-trying-to-use-inspec/8632 "2016-06-06T19:11:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![darknight](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@darknight](https://discourse.chef.io/u/darknight)\
**Post date:** [June 6, 2016, 7:11pm UTC](https://discourse.chef.io/t/kitchen-verify-causes-sudo-failed-and-requires-tty-when-trying-to-use-inspec/8632/1 "2016-06-06T19:11:07Z")

</div>

I am trying to use `chef inspec` to test my cookbook changes. I am testing the installation of `newrelic` package and service from my recipe. When i tried to run `kitchen verify` it fails with `Sudo failed: Sudo requires a TTY`. can any one help me to know what could be wrong here that might not allowing me to verify test cases. Thanks

` Test Directory Path - test/integration/default/inspec/default_spec.rb`

> describe service('nrsysmond') do  
> it { should be\_enabled }  
> it { should be\_running }  
> end

> describe package('newrelic-sysmond') do  
> it { should be\_installed }  
> end

`-----> Verifying <default-rhel-67>... Detected alternative framework tests for `inspec` Search`/Users/abc/code/domain\_chef/newrelic-chef/cookbooks/newrelic/test/integration/default/inspec` for tests

> ------Exception-------  
> Class: Kitchen::ActionFailed  
> Message: Failed to complete #verify action: [Sudo failed: Sudo requires a TTY. Please see the README on how to configure sudo to allow for non-interactive usage.]  
> `

---

<div class="post-metadata">

**Author:** ![chris-rock](https://avatars.discourse-cdn.com/v4/letter/c/e9c0ed/32.png) [@chris-rock](https://discourse.chef.io/u/chris-rock)\
**Post date:** [June 9, 2016, 10:01am UTC](https://discourse.chef.io/t/kitchen-verify-causes-sudo-failed-and-requires-tty-when-trying-to-use-inspec/8632/2 "2016-06-09T10:01:21Z")

</div>

Thanks @darknight It looks like this issue is related to [https://github.com/chef/train/issues/60](https://github.com/chef/train/issues/60) Redhat/Centos have a strange default config for sudo. The simplest solution is to run a helper cookbook to properly configure the sudo configuration e.g. /etc/sudoers.d/chef:

```auto
chef ALL=(root) NOPASSWD: ALL
Defaults!ALL !requiretty

```

Here is an example that configures the system properly from a cookbook: [https://github.com/chef-cookbooks/cis-el7-l1-hardening/blob/master/recipes/enable\_sudo\_no\_tty.rb](https://github.com/chef-cookbooks/cis-el7-l1-hardening/blob/master/recipes/enable_sudo_no_tty.rb)

---

<div class="post-metadata">

**Author:** ![darknight](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@darknight](https://discourse.chef.io/u/darknight)\
**Post date:** [June 10, 2016, 3:18pm UTC](https://discourse.chef.io/t/kitchen-verify-causes-sudo-failed-and-requires-tty-when-trying-to-use-inspec/8632/3 "2016-06-10T15:18:40Z")

</div>

Thanks @chris-rock for the info. I was able to use the above values in a config file and was able to run `kitchen verify` using Inspec.
