question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I tell the ec2 instance to switch to a non-root user via this runner?

See original GitHub issue

All examples I have seen use a docker image, which has a user parameter.

But I’m not using docker. How do I then tell the action-runner to run as non-root (ubuntu in this case)

I tried many different ways, but no matter what I do the current user remains root

      - name: Who Am I?
        run: |
          sudo su - ubuntu
          whoami
      - name: Who Am I?
        run: |
          sudo -u ubuntu bash
          whoami
      - name: Who Am I?
        shell: bash -l {0}
        run: |
          su - ubuntu
          whoami

I can’t find anything on the EC2 side that will let me change the default user. When I connect via ssh it gives the root@ip address.

I have everything already installed/configured under ubuntu.

If this is not the right place to ask if you know where I can find this info please let me know as I have spent many hours searching and can’t find any information.

Thank you!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jpalomakicommented, Aug 29, 2021

While EC2 user data script is run as root, it is possible to use a non-root user if actions-runner is installed as a service (using the svc.sh script). See e.g. https://github.com/philips-labs/terraform-aws-github-runner/blob/develop/modules/runners/templates/install-config-runner.sh#L33

1reaction
jpalomakicommented, Aug 31, 2021

Thank you!

While EC2 user data script is run as root, it is possible to use a non-root user if actions-runner is installed as a service (using the svc.sh script)

Could ec2-github-runner support this?

I think it could, especially now with the newly-added runner-home-dir option (said pre-baked directory could be owned by that non-root user, so file permissions probably would not cause issues).

@machulav what do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run the CodeDeploy agent with a non-root profile
Test the setup by verifying that the CodeDeploy agent is installed and running with the correct user on your Amazon EC2 instance.
Read more >
The Kubernetes executor for GitLab Runner
Read more about resources check during prepare step. ... This example creates a user and group called nonroot and sets the image to...
Read more >
Cloud Agent for Linux Installation Guide
Log into the Qualys Cloud Platform and go to Help >. About to see the URL your hosts need to access. - To...
Read more >
How to setup Remote Execution using non-root user on ...
Check if rexuser can run the sudo commands without password. ... Note: When running Ansible roles on a client using non root user...
Read more >
aws_instance | Resources | hashicorp/aws
user_data - (Optional) User data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user_data_base64 instead.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found