Skip to content

Instantly share code, notes, and snippets.

@Erisa
Last active April 12, 2025 00:04
Show Gist options
  • Select an option

  • Save Erisa/4015ae12211434b8f2f64ac1d731b830 to your computer and use it in GitHub Desktop.

Select an option

Save Erisa/4015ae12211434b8f2f64ac1d731b830 to your computer and use it in GitHub Desktop.
Install the Cloudflare Daemon (cloudflared) in Termux
#!/bin/sh
echo 'NOTE: You can now install cloudflared directly from Termux repos.'
echo 'NOTE: To install it from source instead, open the script and comment out the next two lines.'
pkg install cloudflared
exit
# ^ comment out these lines to proceed with the script
echo "--upgrading packages"
yes "" | pkg update
echo "-- installing dependancies: golang git debianutils make"
yes "" | pkg install golang git debianutils make
echo "-- downloading cloudflared source"
git clone https://github.com/cloudflare/cloudflared.git --depth=1
cd cloudflared
sed -i 's/linux/android/g' Makefile
echo "-- building and installing cloudflared"
make cloudflared
install cloudflared /data/data/com.termux/files/usr/bin
echo "-- done!"
@Isbbrt

Isbbrt commented Jun 29, 2021

Copy link
Copy Markdown

is there how to install it on windows cmd?

@Erisa

Erisa commented Jun 29, 2021

Copy link
Copy Markdown
Author

is there how to install it on windows cmd?

You can do that officially with official instructions: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation#windows

Or install Scoop and simply scoop install cloudflared

@Isbbrt

Isbbrt commented Jun 29, 2021

Copy link
Copy Markdown

is there how to install it on windows cmd?

You can do that officially with official instructions: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation#windows

Or install Scoop and simply scoop install cloudflared

thank you so much

@yelrom0

yelrom0 commented Jul 15, 2021

Copy link
Copy Markdown

The github link specified here is broken. Also, while trying with Termux, the last line

install $GOPATH/bin/cloudflared /data/data/com.termux/files/usr/bin threw me an error : No such file or directory
image

It worked fine for me. Make sure that you run chmod +x before running the script.

@DarremMolko

Copy link
Copy Markdown

It worked like a charm. Thank you so much.

@DarremMolko

Copy link
Copy Markdown

Good news, it has been packaged for Termux and it can now be installed with "pkg i cloudflared" or just "apt install cloudflared" (termux/termux-packages#9304)

@Erisa

Erisa commented Mar 7, 2022

Copy link
Copy Markdown
Author

Good news, it has been packaged for Termux and it can now be installed with "pkg i cloudflared" or just "apt install cloudflared" (termux/termux-packages#9304)

Woah!! I had considered trying to get them to do this at one point but never found the time.
Thank you for letting me know! 🎉♥️

@Erisa

Erisa commented Mar 9, 2022

Copy link
Copy Markdown
Author

Updated the script to notify and install from repos directly, but kept the rest for posterity and in case anyone is curious in future.

@sangelxyz

Copy link
Copy Markdown

Erisa, What is the proper way to run cloudflared from termux. My phone is not rooted. so the
sudo cloudflared service install does not work. Is there another way i can run this as a service from a phone that's not rooted ?

@yelrom0

yelrom0 commented May 21, 2022

Copy link
Copy Markdown

Erisa, What is the proper way to run cloudflared from termux. My phone is not rooted. so the sudo cloudflared service install does not work. Is there another way i can run this as a service from a phone that's not rooted ?

You should be able to run apt update then apt install cloudflared or pkg run cloudflared, don't need root for commands without su or sudo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment