Skip to content

Instantly share code, notes, and snippets.

@kcubeterm
Last active June 30, 2024 04:10
Show Gist options
  • Save kcubeterm/7e2792366bd6e8c14064f7e2ac109cc7 to your computer and use it in GitHub Desktop.
Save kcubeterm/7e2792366bd6e8c14064f7e2ac109cc7 to your computer and use it in GitHub Desktop.
How to install google cloud sdk in termux and run cloud shell interactively.

Now Google cloud sdk support python3.9 as well. Lets start.

Without any surprise,use your copy-paste skills to fire following script into your innocent terminal.

pkg install python3 openssh
curl -o sdk.sh sdk.cloud.google.com
chmod +x sdk.sh
./sdk.sh --install-dir=$PREFIX
Previous version with python2

python 2.7 requires because gcloud does't support python 3.9

pkg install python2 openssh

export CLOUDSDK_PYTHON='python2.7'
echo "export CLOUDSDK_PYTHON='python2.7'" >> ~/.bashrc
echo "export PATH=$PATH:$PREFIX/google-cloud-sdk/bin"
curl -o sdk.sh sdk.cloud.google.com
chmod +x sdk.sh
./sdk.sh --install-dir=$PREFIX
Now just attend few questions and authenticate yourself. reload shell so that all Commmand reloads in your PATH

gcloud auth login

copy link and paste in your default browser, Choose account and copy code then fill that in terminal. now done. Let's do ssh in cloud shell.

gcloud cloud-shell ssh

@Yonle
Copy link

Yonle commented Nov 1, 2021

By the way, During installation, You can skip this part to save space:

Welcome to the Google Cloud SDK!

Do CTRL + C to skip that part. Then link gcloud to $PREFIX/bin

ln -s $PREFIX/google-cloud-sdk/bin/gcloud $PREFIX/bin/gcloud

And execute gcloud. Your gcloud SDK is ready to use.

@BenVella
Copy link

BenVella commented Feb 1, 2024

╭─ ~/projects/gcloud ─────────── ✔  3s  21:57:02 ─╮
╰─ . ./sdk.sh --install-dir=$PREFIX                  ─╯
Downloading Google Cloud SDK install script: https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash
################################################# 100.0%
Running install script from: /data/data/com.termux/files/usr/tmp/tmp.t1AK0OyurM/install_google_cloud_sdk.bash
which curl
/data/data/com.termux/files/usr/tmp/tmp.t1AK0OyurM/install_google_cloud_sdk.bash: line 135: which: command not found
which wget
/data/data/com.termux/files/usr/tmp/tmp.t1AK0OyurM/install_google_cloud_sdk.bash: line 135: which: command not found
Either curl or wget must be installed to download files.
╭─ ~/projects/gcloud ────────────── 1 ✘  21:57:05 ─╮
╰─ which curl                                        ─╯
/data/data/com.termux/files/usr/bin/curl

I'm seeinf this which not found error even though it works just fine in the following request. It seems like whichever environment the Gcloud sdk install is happening in is outside the usual prompt. Tried prefixing a . with no success as well. Any thoughts?

@Yonle
Copy link

Yonle commented Feb 2, 2024

pkg install -y which

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