Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Atlassian Bamboo to setup a build server. It allows the use of "elastic images" which I can specify which of their AMI's to use (I'm using the Amazon Linux/CentOS image). It also allows you to add scripts for essentially "provisioning" the server. When I run the build using sudo in my scripts, I get errors like this:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified

When not using sudo, I get permission denied errors.

The script I'm trying to run is as simple as:

sudo yum install -y php-mysql
sudo yum install -y php-pdo
sudo yum install -y php-pecl-xdebug
sudo yum update

Bamboo is setup with a key so should not require an actual password (there isn't one as far as I know), which means the lack of tty input should not matter, right?

If the server was spun up constantly, I could SSH into it and figure out how to enable sudo privileges, but it's not...it is created, the build is run, and then it terminates.

TL;DR; What can cause a dynamically spun up EBS Backed AMI to not allow sudo?

share|improve this question
    
There is a very clear error message presented to you. Did you search here on SF or the internet in general to find out what it means ? –  Iain Jan 14 at 13:23
    
Yes, I understand roughly what it is saying. Why would it even ask for a password when Bamboo connects over SSH with a key? Additionally, the instance is spun up dynamically, how would I remove requiretty from the /etc/sudoers file if I can't sudo? –  cillosis Jan 14 at 13:24
2  
You need to read the error message carefully - it's nothing to do with ssh passphrases - the clue is sudo:... –  Iain Jan 14 at 13:24
    
@Iain I'm sure it as a very apparent clue to those who know, but I'm just not seeing the "aha moment". I'm guessing, from what I've read, I need to remove requiretty from the /etc/sudoers file, but if I try in my script, it will throw a permission denied. So... –  cillosis Jan 14 at 13:30

3 Answers 3

up vote 1 down vote accepted

Bamboo is setup with a key so should not require an actual password (there isn't one as far as I know), which means the lack of tty input should not matter, right?

No. This is where you're confused. How you authenticated to ssh has nothing to do with sudo. If sudo is configured to require a password, then you have to enter the user's pasword. If you don't, it won't work. If the user doesn't have a password, then it can't possibly work.

It seems you should reconfigure sudo so that

  • it does not require a tty
  • it does not require a password

For example, if I wanted a user named bamboo to be able to execute without a password any command as any user, in my /etc/sudoers file I could have

bamboo  ALL=(ALL)   NOPASSWD: ALL
share|improve this answer
    
This is what I ended up doing. Had to create a custom AMI with that setup already because of the whole dynamic spin up/spin down thing. Thanks for giving an actual answer and not playing a "guess the clue" game! –  cillosis Jan 14 at 18:39

check if the /etc/sudoers file is configured correctly. I had this error messages yesterday when one of our build scripts did overwrite the changes i did in the /etc/sudoers file resulting in the permission issue.

share|improve this answer

As the documentation told you, if the images provided by Atlassian don't do that you want, then you should create a custom image.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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