Skip to content

Instantly share code, notes, and snippets.

@shagamemnon
Created July 16, 2021 05:38
Show Gist options
  • Save shagamemnon/3985df697ec24d8b6df2561e71e70928 to your computer and use it in GitHub Desktop.
Save shagamemnon/3985df697ec24d8b6df2561e71e70928 to your computer and use it in GitHub Desktop.
cloudflared system service on AWS Linux

Configure .cloudflared to run on boot as system service

ssh -i "/path/to/cert.pem" [email protected]
# ...

# Traverse file directory to ~/.cloudflared
cd ~/.cloudflared
# Elevate to root permission
sudo su
# Temporarily append ec2-user PATH to root user path for duration of terminal session
export PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin:$PATH
# Run cloudflared and specify --config flag
cloudflared --config /home/ec2-user/.cloudflared/config.yml service install
# Start service
sudo systemctl start cloudflared
# .. or start on boot with:
sudo systemctl enable cloudflared
# ...

# To test configuration:
sudo reboot
# ...

# SSH back into machine, then:
systemctl status cloudflared
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment