bamboo instance setup script

I've got an AMI that can only be logged in with a user named "centos". This user has "sudo" access as well. How can I configure Bamboo to use the "centos" user to run the "Instance setup script"? It seems the "Instance setup script" will only work if the AMI is configured to login as the "root" user. Can someone shed some light on this for me, i've looked at the documentation and only see comments here or there about the matter.



My AMI has the root login disabled. Therefore it seems as if the "instance setup scripts" don't run at all. Which would make sense if it's trying to login as root. (Although I don't see any failed logs about this) Per the documentation "It's a script that gets run as root user before the agent is started." Therefore is it possible to configure Bamboo to run the "instance setup script" as another user other than root?

1 answer

1 accepted

0 votes
Marcin Oles Atlassian Team Aug 18, 2015


yes, the startup scripts on Linux images are executed as root user. I'm not sure if root user can be disabled completely to such extent that it'll cause the script to stop working, but it usually isn't.

If you really need to use other user than root, then you may try switching the user using e.g. sudo. Didn't test it, but something like this might work:


# code as root here
# ...
# ...

exec sudo -u centos /bin/sh - << EOF

  # code as centos here
  # ...
  # ...


Although be careful with some variables, they might not be set correctly (e.g. $HOME, $USER). Maybe adding -H to sudo command will help.

Or, you could try doing it command by command. Just be careful with single and double quotes. E.g.


sudo -u centos -H sh -c 'echo $HOME'    # out: /home/centos
sudo -u centos -H sh -c "echo $HOME"    # out: /root


=== EDIT ===

The user 'root' is not logging in via SSH. It's just the user that launches the startup scripts. I think it's impossible to disable this user. You can disable logging in as root, but it wouldn't disable startup scripts.

So in your case I'd rather look for another source of error, not in the user calling the scripts. There may be some errors in the scripts in the first place. Or, even more probable, if it's not an AMI build based on an existing Bamboo stock image, the startup script might not be registered to run at startup.

Make sure that your /etc/rc.local executes startup scripts from agent installation directory. This is how it looks like for Bamboo stock images:

File: /etc/rc.local
if [ $? -eq 0 ]; then
    echo "Starting Elastic Bamboo Agent..."
    echo "Elastic Bamboo Agent not started."


Thanks for the response. I added a clarification to my question stating that the root account is disabled via SSH completely. (I can still run "sudo" and "sudo su -" but wouldn't be able to SSH into the root account) Therefore how can I configure Bamboo to run the "instance setup script" as a user other than root?

Marcin Oles Atlassian Team Aug 19, 2015

Hey, I've updated my answer after your clarification, hope it helps.

You're my hero! I indeed was building from scratch with packer and never knew to run /opt/elastic-bamboo-agent/bin/! This has solved my problem, thank you so much for the help!

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,070 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot