EC2 Automatic Instance Sudo Not Working

Jeremy Harris asked:

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?

My 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.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.