In short
A GitHub Actions self-hosted runner is an agent that runs your workflows on your own server instead of GitHub's virtual machines. To set it up, you get a token from the repository settings, download the runner package, register it with config.sh, and start it as a service with svc.sh. A dedicated user, private repositories and an isolated server keep it secure, while a fast CPU and NVMe storage noticeably shorten build times.
In this guide
- What Is a Self-Hosted Runner, and How Is It Different from a GitHub-Hosted Runner?
- Prerequisites
- Step-by-Step Runner Installation
- Using the Self-Hosted Runner in a Workflow
- Security Isolation: The Most Important Part
- Cutting Build Times
- Improving Isolation by Running Jobs in Containers
- Maintenance and Troubleshooting
- Next Step: The Right Server for Your Runner
A GitHub Actions self-hosted runner is a small agent that runs your GitHub Actions workflows on a server you manage instead of the temporary virtual machines GitHub provides. You install the runner on the server, register it with your repository or organization, and it waits for jobs over an outbound HTTPS connection to GitHub. This guide walks you step by step through installing the runner on an Ubuntu VDS, keeping it running as a systemd service, isolating it securely, and practical ways to cut build times.
What Is a Self-Hosted Runner, and How Is It Different from a GitHub-Hosted Runner?
A GitHub-hosted runner is a virtual machine that spins up fresh for each job and is deleted when the job finishes. It is convenient, but the hardware is fixed, caches are downloaded again every time, and private repositories can run out of included minutes. A self-hosted runner runs continuously on your own hardware; you choose the CPU, memory, disk and installed tools.
| Feature | GitHub-hosted runner | Self-hosted runner |
|---|---|---|
| Hardware | Fixed, depends on plan options | Your choice (vCPU, RAM, NVMe) |
| Cache | Downloaded again for every job | Can persist on disk |
| Environment | Clean machine for every job | Persistent; cleanup is your responsibility |
| Internal network access | None | Anywhere the server can reach |
| Maintenance | Handled by GitHub | OS and security are on you |
In short, a self-hosted runner makes sense for teams with long builds, large dependency trees, Docker image builds, and deployments to internal systems.
Prerequisites
- A Linux server running Ubuntu 22.04 or 24.04 with root access
- Admin permission on the repository or organization (to get the runner token)
- Outbound port 443 from the server to
github.commust be open; the runner does not wait for inbound connections, so you do not need to open any extra inbound port - Basic hardening already done; if you have not done it yet, see the first 10 security steps on a new Ubuntu server guide
For build-heavy work, a CPU with strong single-core performance and NVMe storage are the two components that make the biggest difference. That is why AMD Ryzen 9 9950X VDS plans are a good starting point for a runner; DDR5 memory and NVMe storage reduce waiting time during build and test steps.
Step-by-Step Runner Installation
1. Create a dedicated user for the runner
Never run the runner as root. Create a separate user with limited permissions:
sudo adduser --disabled-password --gecos "" runner
sudo su - runner2. Get a registration token from GitHub
- In your repository, go to Settings > Actions > Runners.
- Click New self-hosted runner, then choose Linux as the operating system and x64 as the architecture.
- Copy the download commands and the
--tokenvalue shown on screen. The token is short-lived, so use it right away.
3. Download and extract the runner package
The version number changes often, so use the current command shown on the GitHub page (replace SURUM below with that version number). The general form is:
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-SURUM.tar.gz -L https://github.com/actions/runner/releases/download/vSURUM/actions-runner-linux-x64-SURUM.tar.gz
tar xzf ./actions-runner-linux-x64-SURUM.tar.gzTo install any missing system libraries, run the script bundled with the package once with root privileges:
sudo ./bin/installdependencies.sh4. Register the runner with the repository
./config.sh --url https://github.com/KULLANICI/DEPO \
--token TOKEN_DEGERI \
--name atlas-runner-01 \
--labels ryzen,nvme \
--work _work \
--unattendedThe labels you set with --labels let you target this runner from a workflow. To use it across an organization, put the organization URL in --url instead of the repository URL.
5. Run it as a systemd service
If you start the runner from a terminal with ./run.sh, it stops when the session closes. Install it as a service so it keeps running:
sudo ./svc.sh install runner
sudo ./svc.sh start
sudo ./svc.sh statusThe service name follows the format actions.runner.KULLANICI-DEPO.atlas-runner-01.service. When the server reboots, the runner comes back up automatically and shows as Idle on the Runners page in GitHub.
Using the Self-Hosted Runner in a Workflow
In your workflow file, set runs-on to self-hosted plus your own labels:
name: build
on: [push]
jobs:
derle:
runs-on: [self-hosted, linux, x64, ryzen]
steps:
- uses: actions/checkout@v4
- name: Bağımlılıklar
run: npm ci
- name: Test ve derleme
run: npm test && npm run buildAn idle runner that matches all the labels picks up the job. If you have installed more than one runner, jobs are distributed among them.
Security Isolation: The Most Important Part
A self-hosted runner executes the repository's workflow code on your server. That means anyone who can push code to the repository can run commands on your server. Follow these rules:
- Do not use it with public repositories. A pull request from an outside contributor could run malicious code on the runner. GitHub's self-hosted runner documentation warns about this explicitly.
- Separate user, no sudo. Do not add the runner user to the sudo group. Keep in mind that adding the user to the
dockergroup effectively grants near-root access. - Separate server. Do not install the runner on the server that hosts your production database or website. A separate KVM virtual server for build jobs limits the blast radius of any compromise to that machine.
- Ephemeral runner. If you add
--ephemeralto theconfig.shcommand, the runner takes a single job and then removes its registration. If every job must run in a clean environment, use this mode together with some automation. - Secrets. Pass secrets only through GitHub Secrets, never write them to the server's disk in plain text, and clean the
_workdirectory regularly. - Firewall. Allow only SSH for inbound traffic; a simple UFW rule set is enough for this.
Cutting Build Times
The real payoff of a self-hosted runner is speed. These settings make the biggest difference:
- Pick a fast CPU. Compilers, bundlers and test runners are highly sensitive to single-core speed and memory bandwidth. The Zen 5-based Ryzen 9 9950X with DDR5 memory is strong on both.
- Keep caches on disk. npm, Composer, Maven, Gradle and pip caches stay in the runner user's home directory and are not downloaded again for each job. NVMe storage speeds up access to these files.
- Docker layer cache. For jobs that build images, layers stay on the server, so only changed layers are rebuilt. To install Docker, follow the how to install Docker on Ubuntu guide.
- Parallel builds. Use all vCPUs with options such as
make -j$(nproc). As a rough guideline, allow 1-2 GB of RAM per parallel build job. - Multiple runners. Install two runners in different directories on the same server to increase the number of concurrent jobs; with enough vCPU and RAM, queue wait times drop.
If you want an always-on build machine, the SA-R9-9950X-4 with 4 vCPUs and 8 GB of DDR5 RAM is a balanced choice for most web and mobile projects. During release weeks or large test matrices, when you need extra capacity, you can add temporary runners with an hourly Ryzen VDS that you spin up for a few hours and delete when the work is done. We explain how the hourly model works in detail in What is an hourly VDS?
Improving Isolation by Running Jobs in Containers
Because the runner is a persistent machine, files left behind by one job, packages it installed, or environment variables it changed can affect the next job. A practical way to reduce this is to run job steps inside a container. In GitHub Actions, the container key does this in a single line:
jobs:
test:
runs-on: [self-hosted, linux, ryzen]
container:
image: node:20-bookworm
steps:
- uses: actions/checkout@v4
- run: npm ci && npm testWith this setup, build tools are installed in the image rather than on the server, so different projects can use different Node.js, PHP or Python versions without breaking each other. The container feature requires Docker on a Linux runner, and the runner user needs access to Docker; that makes the "separate server" rule above even more important. Installing the runner on a VDS dedicated solely to build jobs limits the risk that comes with Docker access to that machine.
Maintenance and Troubleshooting
- Updates: By default, the runner updates itself automatically. You still need to apply operating system updates regularly with
apt. - Runner shows as Offline: Check the logs with
sudo ./svc.sh statusandjournalctl -u actions.runner.* -f. Usually the cause is blocked outbound traffic or a stopped service. - Disk filling up: The
_workdirectory and old Docker images grow over time. Scheduledocker system pruneas a cron job. - Removing the runner: First stop and uninstall the service, then delete the registration:
sudo ./svc.sh stop
sudo ./svc.sh uninstall
./config.sh remove --token KALDIRMA_TOKENINext Step: The Right Server for Your Runner
For a persistent CI machine, check out the Ryzen 9 9950X VDS options with strong single-core performance, DDR5 memory and NVMe storage; with KVM virtualization and root access, you can configure the runner however you like. For workloads that spike now and then, use hourly Ryzen servers to add capacity only for the hours you need it. Servers run in Sunucu Atlas's Istanbul data center; if you get stuck during setup, open a support ticket to get help.
Frequently asked questions
Is a GitHub Actions self-hosted runner free?
The runner software is open source and free; on the infrastructure side, you cover the cost of the server. GitHub's Actions billing terms change from time to time, so check GitHub's pricing page for the current rules that apply to your plan.
Do I need to open any ports on the server for a self-hosted runner?
No. The runner waits for jobs over an outbound HTTPS (443) connection to GitHub and does not need inbound connections. Keeping only SSH open for inbound traffic is enough.
Can I use a self-hosted runner with a public (open source) repository?
It is not recommended. Pull requests from outside contributors could run code on the runner and put your server at risk; use self-hosted runners with private repositories.
Can I install more than one runner on a single server?
Yes. Install each runner in its own directory and register it under a different name to increase the number of concurrent jobs; you need enough vCPU and RAM for the number of jobs.
How many vCPUs and how much RAM does a runner need?
Small web projects run fine with 2 vCPUs and 4 GB of RAM; for parallel builds, Docker image builds or large test suites, 4-8 vCPUs and 8-16 GB of RAM are more comfortable. These figures are guidelines, so measure your own build times before deciding.