sudo: no tty present and no askpass program specified jenkins

1,179 views
Skip to first unread message

niraj nandane

unread,
Oct 13, 2014, 1:15:52 AM10/13/14
to jenkins...@googlegroups.com
I have one build machine which have a user "abc" which is not a root user and have limited sudo access. when I checkout source code and run build script it works fine. The build script contains sudo command for which it does not say "sudo: no tty present and no askpass program specified". But when did same thing from jenkins on that build machine added as slave,it shows "sudo: no tty present and no askpass program specified".

  I have got one solution saying comment "Default requiretty" in /etc/sudoers file. But I don’t have access to this file.

How I can overcome this problem?

Richard Bywater

unread,
Oct 13, 2014, 5:12:04 AM10/13/14
to jenkins...@googlegroups.com
The problem will most likely be that sudo requires (in the default configuration) a password to be entered before sudo commands can be run. The only way to fix this is probably going to be to get the guys who have access to the /etc/sudoers file to allow the user that needs to run the sudo command (i.e. the user under which Jenkins is running) to run a password-less sudo session for either all commands (unlikely I'd imagine) or for the particular commands being run.

Richard.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

niraj nandane

unread,
Oct 13, 2014, 5:43:55 AM10/13/14
to jenkins...@googlegroups.com
Hi, you are right . The user under which i am running jenkins on that slave have all permission that are needed for build. The build gets completed if i go and run script on that slave. But if i run same script through jenkins ,it is showing the error

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/JUpplb7mV3k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks and regards--
Niraj Nandane(Vit pune)

Richard Bywater

unread,
Oct 13, 2014, 6:11:59 AM10/13/14
to jenkins...@googlegroups.com
Hmm my sudo is a bit rusty - but perhaps you could list the output of "sudo -ll" which I think will make it a bit easier to read.

Also what command/s is the build doing when it gets prompted (and I assume Jenkins is running as the user skhandeb?)

Richard.

PS Please keep discussions on the list as that way others can jump in and help out if they see the potential issue :)

On Mon, Oct 13, 2014 at 11:02 PM, niraj nandane <niraj....@gmail.com> wrote:
Hi,
The idea is the buildmachine have access for 3 hrs to build server. When i run build on build machine without using jenkins its get completed and dont ask ever password . The script i run also have sudo stmts. But when we run same script from jenkins its say above error.

The output of sudo -l is

User skhandeb may run the following commands on this host:
    (habdbsync) NOPASSWD: ALL, (habdbsync) !/bin/sh, !/bin/ksh, !/bin/csh, !/bin/tcsh, !/bin/zsh, !/bin/bash, (habdbsync) !/bin/su,
    (habdbsync) !/usr/bin/ssh, !/usr/bin/scp, !/usr/bin/slogin
    (root) /bin/chown habdbsync /devbuild/*
    (root) /bin/chown -R root\:root /devbuild/*
    (root) /bin/chown root\:root /devbuild/*
    (root) /bin/true

niraj nandane

unread,
Oct 13, 2014, 7:03:22 AM10/13/14
to jenkins...@googlegroups.com
output of sudo -l

(habdbsync) NOPASSWD: ALL, (habdbsync) !/bin/sh, !/bin/ksh, !/bin/csh, !/bin/tcsh, !/bin/zsh, !/bin/bash, (habdbsync) !/bin/su,
    (habdbsync) !/usr/bin/ssh, !/usr/bin/scp, !/usr/bin/slogin
    (root) /bin/chown habdbsync /devbuild/*
    (root) /bin/chown -R root\:root /devbuild/*
    (root) /bin/chown root\:root /devbuild/*
    (root) /bin/true
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/JUpplb7mV3k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

niraj nandane

unread,
Oct 13, 2014, 7:06:21 AM10/13/14
to jenkins...@googlegroups.com
 sudo -u root chown habdbsync  <some files>
This stmt is making above "no tty" output

Richard Bywater

unread,
Oct 13, 2014, 4:15:16 PM10/13/14
to jenkins...@googlegroups.com
From my rudimentary knowledge, it doesn't look like NOPASSWD has been specified for running that command and so I'd expect it to prompt for the password (and hence get the issue you are seeing).

I could be wrong though as I don't have a setup available to me which has similar sudoers settings :)

Richard.


You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Jeffrey Parker

unread,
Oct 13, 2014, 4:21:39 PM10/13/14
to jenkins...@googlegroups.com
That is exactly what the problem is, but the bigger issue is running sudo commands in a script like this is generally bad practice. The more correct way to do it is to make sure that all files are already owned by the correct user or that the user that is running the command has permission to change ownership of those files.

John D. Ament

unread,
Oct 13, 2014, 8:51:27 PM10/13/14
to jenkins...@googlegroups.com
are you sure it's NOPASSWD?  Seems like you need to turn off require tty in your sudoers file.

niraj nandane

unread,
Oct 14, 2014, 12:39:41 AM10/14/14
to jenkins...@googlegroups.com
Hi All,
I got solution for this by using SUDO_ASKPASS program.
Thanks,
Niraj
Reply all
Reply to author
Forward
0 new messages