The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,224 other followers

Free Linux cloud shell for Gmail users – shell in the browser that works in all locations I’ve been so far

Posted by jpluimers on 2020/05/18

This is still so cool: [WayBack] Free Linux cloud shell for Gmail users … – Adrian Marius Popa – Google+:

Free Linux cloud shell for Gmail users

https://news.ycombinator.com/item?id=16247577

comments are more interesting

“If you want a free Linux box with a Public IP and SSH, I’d recommend spinning up an f1-micro VM. It’s part of the permanent free tier”

https://news.ycombinator.com/item?id=16248668

Even cooler is that you can use it both from a web browser and from your own console, more on that below.

Cloud Shell from the web

The above links:

I still need to use the f1-micro VM instance (my cloud and self hosted stuff is in different locations), but the cloud shell has saved my butt for so many times by now that I lost count.

Basically the shell worked everywhere I tried, where stuff like shellinabox [WayBack], anyterm [WayBack] or [WayBackajaxterm/qweb [WayBack] fail.

Each time you logon, you will be connected to a VM, so it takes a few seconds while you see

Establishing connection to your Google Cloud Shell

Establishing connection to your Google Cloud Shell

If you have not used it for a while, then it takes a bit longer as some provisioning needs to take place which can take about a minute at slow times:

Provisioning your Google Cloud Shell machine... Since you haven't used your Cloud Shell for a while, it may take some time to unarchive your disk.

Provisioning your Google Cloud Shell machine… Since you haven’t used your Cloud Shell for a while, it may take some time to unarchive your disk.

After 60 minutes of inactivity, it will disconnect:

Your Google Cloud Shell session was idle for over 60 minutes and terminated.

Your Google Cloud Shell session was idle for over 60 minutes and terminated.

 

Like a regular ssh client, the [WayBack] Secure Shell – Chrome Web Store Terminal emulator and SSH client fails in many situations because a lot of places block outgoing traffic over other ports than http (TCP port 80) and https (TCP port 443).

More links:

Cloud Shell from the MacOS console

Shortly after the Google Cloud Shell announcement, access got extended beyond the web interface: [WayBack] Google Cloud Platform Blog: Introducing the ability to connect to Cloud Shell from any terminal.

That page only shows how you use console access to the Google Cloud Shell, not how to install it. So below are the installation instructions on a Mac with MacOS/Mac OS X/OS X.

Installing the console client for Google Cloud Shell access.

The easiest way to install the console client is by using homebrew [WayBack] and running these commands (a detailed gist with output is at the end)

brew install caskroom/cask/google-cloud-sdk
gcloud alpha
gcloud alpha cloud-shell ssh
gcloud auth login
gcloud alpha cloud-shell ssh

Somehow this fails. See the log below.

Related links:

Via: [WayBack] Introducing the ability to connect to Cloud Shell from any terminal Introducing the ability to connect to Cloud Shell from any terminal… – Adrian Marius Popa – Google+

The Cloud Shell runs on an f1-micro VM instance

If you are contemplating about using an f1-micro VM instance, it pays to know that the Cloud Shell runs on one (see the “log” in the “about” below).

A few years ago, the OpsDash people did some analysis on what performance the f1-micro VM actually provides  [WayBack] Exploring the Google Cloud f1-micro Instance – OpsDash did.

From the “about” the Cloud Shell shows that it consists of.

Google Cloud Shell

Free, pre-installed with the tools you need for the Google Cloud Platform. Learn More
jeroen_pluimers_com@cloudshell:~$
jeroen_pluimers_com@cloudshell:~$ gcloud compute instances list
NAME           ZONE           MACHINE_TYPE PREEMPTIBLE INTERNAL_IP    EXTERNAL_IP     STATUS
example-vm-1   asia-east1-a   f1-micro                 10.240.160.142 104.155.216.228 RUNNING
example-vm-2   europe-west1-b f1-micro                 10.240.119.112 104.155.36.122  RUNNING
example-vm-3   us-central1-f  f1-micro                 10.240.57.1    104.154.76.241  RUNNING
jeroen_pluimers_com@cloudshell:~$
jeroen_pluimers_com@cloudshell:~$ git clone https://github.com/GoogleCloud/appengine-example.git
Cloning into 'appengine-example'...
remote: Counting objects: 476, done.
remote: Total 476 (delta 0), reused 0 (delta 0), pack-reused 476
Receiving objects: 100% (476/476), 432.65 KiB | 0 bytes/s, done.
Checking connectivity... done.
jeroen_pluimers_com@cloudshell:~$ cd appengine-example
jeroen_pluimers_com@cloudshell:~/appengine-example$ appcfg.py -A test-project update app.yaml
10:35 PM Host: appengine.google.com
10:35 PM Application: test-project; version: 1
Starting update of app: test-project, version: 1
10:35 PM Cloning 1 static file.
10:35 PM Cloning 5 application files.
10:35 PM Compilation starting.
10:35 PM Compilation completed.
10:35 PM Starting deployment.
10:35 PM Checking if deployment succeeded.
10:35 PM Deployment successful.
10:35 PM Checking if updated app version is serving.
10:35 PM Completed update of app: test-project, version: 1
jeroen_pluimers_com@cloudshell:~/appengine-example$

Real Linux environment

  • Linux Debian-based OS
  • 5GB persisted home directory
  • Add, edit and save files

Configured for Google Cloud

  • Google Cloud SDK
  • Google App Engine SDK
  • Docker
  • Git
  • Text editors
  • Build tools

–jeroen

$ brew install caskroom/cask/google-cloud-sdk
==> brew cask install caskroom/cask/google-cloud-sdk 
==> Caveats
google-cloud-sdk is installed at /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk. Add your profile:

  for bash users
    source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc'
    source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc'

  for zsh users
    source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc'
    source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc'

==> Satisfying dependencies
==> Downloading https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
######################################################################## 100.0%
==> No checksum defined for Cask google-cloud-sdk, skipping verification
==> Installing Cask google-cloud-sdk
==> Running installer script 'google-cloud-sdk/install.sh'
==> Welcome to the Google Cloud SDK!
==> 
==> 
==> Your current Cloud SDK version is: 195.0.0
==> Installing components from version: 195.0.0
==> 
==> +----------------------------------------------------------------------------+
==> |                    These components will be installed.                     |
==> +-----------------------------------------------------+------------+---------+
==> |                         Name                        |  Version   |   Size  |
==> +-----------------------------------------------------+------------+---------+
==> | BigQuery Command Line Tool                          |     2.0.30 | < 1 MiB |
==> | BigQuery Command Line Tool (Platform Specific)      |     2.0.26 | < 1 MiB |
==> | Cloud SDK Core Libraries (Platform Specific)        | 2018.03.16 | < 1 MiB |
==> | Cloud Storage Command Line Tool                     |       4.29 | 3.4 MiB |
==> | Cloud Storage Command Line Tool (Platform Specific) |       4.27 | < 1 MiB |
==> | Default set of gcloud commands                      |            |         |
==> | gcloud cli dependencies                             | 2017.10.20 | 1.4 MiB |
==> +-----------------------------------------------------+------------+---------+
==> 
==> For the latest full release notes, please visit:
==>   https://cloud.google.com/sdk/release_notes
==> 
==> #============================================================#
==> #= Creating update staging area                             =#
==> #==================
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> #
==> #= Installing: BigQuery Command Line Tool                   =#
==> #
==> =
==> ==
==> ==
==> ====
==> ==
==> ===
==> ==
==> ==
==> ==
==> ===
==> =
==> ===
==> =
==> ==
==> =
==> =
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> ==
==> =
==> =#
==> #= Installing: BigQuery Command Line Tool (Platform Spec... =#
==> #
==> ==============================
==> ==============================#
==> #= Installing: Cloud SDK Core Libraries (Platform Specific) =#
==> #
==> ==============================
==> ==============================#
==> #= Installing: Cloud Storage Command Line Tool              =#
==> #
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> #
==> #= Installing: Cloud Storage Command Line Tool (Platform... =#
==> #
==> ==============================
==> ==============================#
==> #= Installing: Default set of gcloud commands               =#
==> #============================================================#
==> #= Installing: gcloud cli dependencies                      =#
==> #
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> =
==> ==========
==> =========
==> ==
==> =
==> =====
==> ==#
==> #= Creating backup and activating new installation          =#
==> #============================================================#
==> 
==> Performing post processing steps...
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> .
==> done.
==> 
==> 
==> This will install all the core command line tools necessary for working with
==> the Google Cloud Platform.
==> 
==> Update done!
==> 
==> ==> Source [/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc] in your profile to enable shell command completion for gcloud.
==> ==> Source [/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc] in your profile to add the Google Cloud SDK command line tools to yo
==> 
==> For more information on how to get started, please visit:
==>   https://cloud.google.com/sdk/docs/quickstarts
==> 
==> 
==> Linking Binary 'bq' to '/usr/local/bin/bq'.
==> Linking Binary 'gcloud' to '/usr/local/bin/gcloud'.
==> Linking Binary 'git-credential-gcloud.sh' to '/usr/local/bin/git-credential-gcloud'.
==> Linking Binary 'gsutil' to '/usr/local/bin/gsutil'.
🍺  google-cloud-sdk was successfully installed!

$ gcloud alpha
You do not currently have this command group installed.  Using it 
requires the installation of components: [alpha]


Your current Cloud SDK version is: 195.0.0
Installing components from version: 195.0.0

┌──────────────────────────────────────────────┐
│     These components will be installed.      │
├───────────────────────┬────────────┬─────────┤
│          Name         │  Version   │   Size  │
├───────────────────────┼────────────┼─────────┤
│ gcloud Alpha Commands │ 2017.09.15 │ < 1 MiB │
└───────────────────────┴────────────┴─────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?  Y

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud Alpha Commands                        ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation          ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done.                                                                                                                       

Update done!

Restarting command:
  $ gcloud alpha

ERROR: (gcloud.alpha) Command name argument expected.
Usage: gcloud alpha [optional flags] <group | command>
  group may be           app | auth | billing | cloud-shell | compute | config |
                         container | dataflow | deployment-manager | emulators |
                         endpoints | firebase | functions | genomics | iot |
                         kms | ml | ml-engine | monitoring | organizations |
                         projects | pubsub | resource-manager | resources |
                         scheduler | services | source | spanner | tasks
  command may be         init | interactive | search-help

For detailed information on this command and its flags, run:
  gcloud alpha --help

$ gcloud alpha cloud-shell ssh
ERROR: (gcloud.alpha.cloud-shell.ssh) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

Console starting step:

$ gcloud auth login
Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&access_type=offline


WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
  gcloud auth application-default --help

Web steps:

  1. Select an account
  2. Confirm the access level
  3. At success you end up at https://cloud.google.com/sdk/auth_success

Console finishing when the success page displayed:

You are now logged in as [jeroen.pluimers.com@gmail.com].
Your current project is [None].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID

$ gcloud alpha cloud-shell ssh
WARNING: The public SSH key file for gcloud does not exist.
WARNING: The private SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/jeroenp/.ssh/google_compute_engine.
Your public key has been saved in /Users/jeroenp/.ssh/google_compute_engine.pub.
The key fingerprint is:
SHA256:
........................................... jeroenp@RMBPro1TBJWP.local
The key's randomart image is:
+---[RSA 2048]----+
...................
+----[SHA256]-----+
ERROR: (gcloud.alpha.cloud-shell.ssh) PERMISSION_DENIED: Cloud Shell API has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudshell.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
- '@type': type.googleapis.com/google.rpc.Help
  links:
  - description: Google developers console API activation
    url: https://console.developers.google.com/apis/api/cloudshell.googleapis.com/overview?project=google.com:cloudsdktool

The problem is that the URL returns a failure so it cannot be used to enable the API:

https://console.developers.google.com/apis/api/cloudshell.googleapis.com/overview?project=google.com:cloudsdktool -> The API "cloudshell.googleapis.com" doesn't exist or you don't have permission to access it

The API "cloudshell.googleapis.com" doesn't exist or you don't have permission to access it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: