Answers: <p><a href="https://github.community/t/execute-commands-with-sudo/121264" rel="nofollow noreferrer">airtower-luna from GitHub community answered it here and it worked for me</a>
  Answer pasted below:
  The command in your workflow file is not the same as the one in your sudoers file, sudo doesn’t know they are functionally equivalent. Use twentydb.service in the workflow, too.</p>
  <p>Also, is the user your runner runs as in the sudo group? If not, that entry won’t apply to it. However, I’d suggest using a separate entry for the user rather than adding the runner to the sudo group.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-07-04T13:00:45.673Z
Answers: 2020-07-04T13:00:45.673Z
Answers: Takasur
Body: <p>I have a GitHub action set on self hosted Ubuntu VPS on Linode.
  I ran <code>sudo ./svc.sh install</code> and then <code>./svc.sh start</code>. The runner is up and working but I have a command in my yaml file that needs to run as sudo. I have this command in sudoers file to run without sudo
  <code>%sudo ALL= NOPASSWD: /bin/systemctl restart twentydb.service</code>
  But still when I push on the server the following error occurs.
  <code>sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper</code></p>
  <pre><code>name: restart the service
  run: |
  sudo systemctl restart twentydb
  </code></pre>
  <p>I also need to set up 2 more runners on the same server and same setup.</p>
  
Tags: <linux><continuous-deployment><github><github-actions>
Title: GitHub Actions Runner execute commands with sudo GitHub Actions
UserDisplayName: Takasur
ThreadText: # GitHub Actions Runner execute commands with sudo GitHub Actions
  
  (Asked by: username_0 on 2020-07-04)
  
  I have a GitHub action set on self hosted Ubuntu VPS on Linode.
  I ran `sudo ./svc.sh install` and then `./svc.sh start`. The runner is up and working but I have a command in my yaml file that needs to run as sudo. I have this command in sudoers file to run without sudo
  `%sudo ALL= NOPASSWD: /bin/systemctl restart twentydb.service`
  But still when I push on the server the following error occurs.
  `sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper`
  
  ```
  name: restart the service
  run: |
  sudo systemctl restart twentydb
  
  ```
  
  I also need to set up 2 more runners on the same server and same setup.
  
  **Tags:** linux, continuous-deployment, github, github-actions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-07-04. Score: 3
  
  [airtower-luna from GitHub community answered it here and it worked for me](https://github.community/t/execute-commands-with-sudo/121264)
  Answer pasted below:
  The command in your workflow file is not the same as the one in your sudoers file, sudo doesn’t know they are functionally equivalent. Use twentydb.service in the workflow, too.
  
  Also, is the user your runner runs as in the sudo group? If not, that entry won’t apply to it. However, I’d suggest using a separate entry for the user rather than adding the runner to the sudo group.
  
  
  ---
  
  