With this guide you can use a bash shell script inside a Termux terminal on your Android phone, to connect to your Chromecast using it's WiFi hotspot and do the Chromecast initial setup, without having to install Google spyware apps.
Warning
This is specifically for 1st, 2nd & 3rd Generation Chromecast, Chromecast Audio and Chromecast Ultra.
It's not applicable for any Chromecast with Google TV, as they can be configured directly using a remote or keyboard.
This guide uses the castanet.sh fork by @DavidePrincipi, which swaps the problematic nodejs dependency for openssl. Using openssl allows for easy use of this script on many Linux distributions, as a large number already have openssl installed by default.
As a result, this guide should also work for other mobile and desktop versions of Linux as well.
Credit to interfect for the original castanet.sh script and DavidePrincipi for the castanet.sh fork on which this guide is based.
Download and install the 'Suggested' (latest stable) version of Termux from F-Droid.
If you already have an alternative terminal installed, you can use that if it supports bash scripts.
If you're using a desktop Linux distribution, you already have access to a terminal of some description, so keep calm and carry on. π
To install the required dependencies, use the following command:
pkg install which curl jq openssl-tool
If you're in another terminal or Linux distro, adjust accordingly for your package manager. (pkg for apt, dnf, etc, etc.)
curl -O https://gist.githubusercontent.com/DavidePrincipi/e2007b998bb66ea69a1ff7832af6c417/raw/castanet.sh && chmod +x castanet.sh
Firstly, we will remove the use of the /tmp/ directory for when encrypting the pubkey, as the Android OS permissions are more restrictive than usual Linux distributions. Otherwise, the script will throw a permission error (unless your 'droid is rooted).
sed -i 's|/tmp/chromecast_pubkey.pem|chromecast_pubkey.pem|g' castanet.sh
Secondly, we will update the encryption command used on the WiFi password, otherwise when the script calls openssl, it will spit out The command rsautl was deprecated in version 3.0. Use 'pkeyutl' instead. π
sed -i 's|openssl rsautl -encrypt -pubin -inkey "$PUBKEY_FILE" -pkcs|openssl pkeyutl -encrypt -pubin -inkey "$PUBKEY_FILE" -pkeyopt rsa_padding_mode:pkcs1|g' castanet.sh
If the Chromecast previously had a WiFi connection and has lost it, it will automatically go into setup mode in an effort to get an accessible WiFi connection.
Alternately, you can Factory Reset (wipe) your Chromecast manually by holding down the button on it. The LED should begin to blink. When the LED light turns white, release the button and the Chromecast should then restart into setup mode.
When the Chromecast is in setup mode, it will show it's current WiFi Hotspot SSID/Name on screen. The factory default Hotspot SSID will usually be in the format of Chromecast#### and the Chromecast IP address will usually be 192.168.255.249 (which you should now verify by checking your default gateway in your WiFi settings once connected to the hotspot).
Important
Make sure to choose to "Stay connected" when Android throws you the Chromecast#### has no internet access notification, otherwise the script won't be able to connect to your Chromecast correctly.
Set the Chromecast name and opt out of some telemetry:
curl --insecure --tlsv1.2 --tls-max 1.2 -H "content-type: application/json" -d '{"name": "YourChromecastName", "opt_in": {"crash": false, "stats": false, "opencast": false}}' https://${CHROMECAST_IP}:8443/setup/set_eureka_info
Verify Chromecast device information:
curl --insecure --tlsv1.2 --tls-max 1.2 https://192.168.255.249:8443/setup/eureka_info | jq .
Note
The rest of these commands are only relevant if you haven't factory reset your Chromecast. If you did factory reset your Chromecast to get to the WiFi setup screen, then these commands will not provide anything as the Chromecast hasn't been configured for any WiFi networks yet. π
List known networks:
curl --insecure --tlsv1.2 --tls-max 1.2 https://192.168.255.249:8443/setup/configured_networks | jq .
Forget a network:
curl --insecure --tlsv1.2 --tls-max 1.2 -H "content-type: application/json" -d '{"wpa_id": 0}' https://192.168.255.249:8443/setup/forget_wifi
CHROMECAST_IP="192.168.255.249" WIFI_SSID="XXX" WIFI_PASSWORD="XXX" ./castanet.sh
CHROMECAST_IP is the IP for the Chromecast, as you verified in Step 4. WIFI_SSID and WIFI_PASSWORD are the credentials for the network that the Chromecast will be configured for once the script is complete.
Once the WiFi setup is complete, the script will show you the WiFi information (signal level, encryption, frequency, etc.), Chromecast's WiFi hotspot will then disappear and you should start seeing the Google backdrop photos on your Chromecast. Try casting from your device and you should be good to go.