15

I have sh script in jenkins which has sudo ssh command and I am getting this error

Warning: Identity file key.pem not accessible: Permission denied.
Host key verification failed.
sudo: no tty present and no askpass program specified

I have found solutions saying add

jenkins ALL=(ALL) ALL

these lines in /etc/sudoers but still its not working.

5
  • problems with not permissions, may be in your script use ssh on remote machine? sudo: no tty present and no askpass program specified - error if you want run action without terminal(for write pass/etc).
    – plsgogame
    Commented Jul 30, 2013 at 7:45
  • @amisuno when I run it in terminal its fine problem is when jenkins runs it.
    – Uday Reddy
    Commented Jul 30, 2013 at 8:14
  • i know, because jenkins doesn't have terminal.
    – plsgogame
    Commented Jul 30, 2013 at 8:25
  • @amisuno so how do I solve it??
    – Uday Reddy
    Commented Jul 30, 2013 at 8:45
  • try add to sudoers NOPASSWD: ALL like this : jenkins ALL= NOPASSWD: ALL
    – plsgogame
    Commented Jul 30, 2013 at 8:51

2 Answers 2

44
sudo su    
visudo -f /etc/sudoers

add add following line at the end.

jenkins ALL= NOPASSWD: ALL
2
  • I need to restart? Commented Mar 30, 2017 at 13:14
  • 2
    the best answer ever. I was struggling for hours on google.
    – vicky
    Commented Jul 24, 2020 at 17:28
0

username ALL= NOPASSWD: ALL in sudoers worked in ubuntu server 12.04.2

1
  • 7
    Please provide more context for your answer Commented Oct 4, 2013 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.