Gitlab Runner Error: sudo: no tty present and no askpass program specified

Gitlab Runner Error: sudo: no tty present and no askpass program specified

Get Social!

After issuing the first build on a dynamically created Container I came across the following build error when running a command with sudo.

sudo: no tty present and no askpass program specified

The error is caused by trying to run a command with sudo, however the calling user has not been authorised to use sudo. The error isn’t helpful, and doesn’t really spell out where to go, but adding the calling user to the sudoers file will save the day.

Solution

Open up the sudoers file for editing in your favorite editor.

vi /etc/sudoers

And add your gitlab runner user to the bottom. If you installed your gitlab runner from the official apt repositories then your gitlab-runner process will run under the gitlab-runner user.

Add the following to the bottom of the file:

gitlab-runner ALL=(ALL) NOPASSWD: ALL

Retry your build and you should be back in business!

 


10 Comments

Manohara Babu Chennuru

28-Mar-2018 at 3:11 pm

It did not work for me.

    wangjin

    14-Jun-2018 at 11:05 am

    check your runner type change it from shell to ssh

wangjin

14-Jun-2018 at 11:04 am

Did not solve my problem…..
this can solve it ,someone like me
[[runners]]
name = “3.0.1_node2”
url = “http://XXXXXXX/”
token = “07c5286e147eda5ba60e333e135366”

executor = “ssh” ###if you not this type, eg “shell ” may cause this problem……
[runners.ssh]
user = “root”
password = “x.x.x.x”
host = “x.x.x.x”

Julio Marin

22-Jul-2019 at 9:33 pm

Thanks, works perfectly

phiere

23-Nov-2019 at 10:07 am

thanks , works for me.

Dmitry

9-Dec-2019 at 4:12 pm

thank you

Anne Lorayne Moreira

23-Jan-2020 at 5:22 pm

Thank you \o

Neha V

27-Jan-2020 at 6:37 pm

Thanks for this helpful post!

Daniel R

4-Sep-2020 at 10:47 pm

Can you change what you wrote from “Open up the sudoers file for editing in your favorite editor.” That is a TERRIBLE idea, as I learned first hand – if “your favorite editor” dose not save with the normal ASCII syntax (as is the case with my favorite gedit) then etc/sudoers becomes unreadable and unwriteable (because no one is recognized as a sudouser). The file should be edited with `visudo` which checks for incorrect syntax.

Jim

11-Sep-2020 at 8:23 am

Worked for me, cheers.

However one note, It is not advised to edit the sudoers file directly, use visudo, make your mods, then Ctrl+o then Ctrl+x to save and exit.

visudo runs a lint over your edits and makes sure all edits will be OK and tries to help make sure you will not lock yourself out of the sudo functionality.

Jim

Leave a Reply

Visit our advertisers

Quick Poll

Do you use ZFS on Linux?

Visit our advertisers