Using Google Cloud Shell Editor on an instance - google-cloud-platform

I am using the Beta version of Google's newer file browser along with the web based shell window to access my Google Cloud instance (https://cloud.google.com/shell/docs/features#code_editor).
I want to use the new file editor, when it initially loads it shows the files in my dev shell instances, when I boot up the actual instance I want to work in the files still show those from my persistent storage.
Can I get this window to show the files on the instance, so I can edit them on the fly?
As you can see in the screenshot below, files shown in the top left window do not match those in the active directory on the instance, can I tell the file browser to look at the instance?

No, unfortunately you cannot view/edit files on the remote instance to which you are connecting. Think of Google Cloud Shell as your workstation in the cloud and the web editor runs right on that workstation: when you connect to a remote machine you cannot see it's filesystem directly.
You could, however, install a web editor on your remote instance. Google Cloud Shell uses open-source Orion editor that's pre-installed on the Cloud Shell VM.

You can run vscode in your browser locally with connection to remote google cloud vm instance. Needs to download code-server and the repo supplies a binary version. After downloading, you caninstall it on the GCP vm instance and run vscode in your browser.
Hope this blog and video will also help.

Related

Add user while instance creation in google cloud

I want to create users in windows server on google cloud during instance creation. Searched in google cloud documentation and other sites but could not find answers. I am aware of startup scripts but those are great when you want to do something every time machine boots up. Please help.
You can use GCP startup script to do it. Please have a look at the documentation Running startup scripts. For example, you can easily add a user John and add him to the group Remote Desktop Users by using metadata:
and, as a result, you'll be able to login via RDP to your VM instance with login John and password fadf24as.FD*.
By default such script will be executed during each start cycle of VM instance:
Compute Engine lets you create and run your own startup scripts on
your virtual machine (VM) instances to perform automated tasks every
time your instance boots up.
To change this default behavior you can add there additional step like creating some folder or file and use them as a flag: if folder or file already exist than rest part of the script should be skipped. In such case PowerShell looks more suitable than cmd, final script could be uploaded from Google Cloud Bucket.

How do i change the Cloud Shell Editor explorer to show Compute filesystem

I created a Compute instance with Ubuntu and would like to use it as a development environment, with the cloud shell editor as the IDE. I know how to ssh in the shell, but, the editor won't allow to browse the filesystem on the Compute instance. Please Help.
You would need to use a third-party tool for this. Cloud Shell does not have built-in support to browse external file systems.

Error when trying to connect to a Cloud SQL instance using the Cloud Shell

I've had a Cloud SQL instance for about a year now.
I always accessed it the same way:
I would go to my project on the Cloud Console.
Click on the Cloud Shell icon at the top right (a small right pointing arrow).
A black shell screen would pop up where I would type
gcloud sql connect <my instance> --user=root.
Enter my password.
Now, all of a sudden, I am getting an error message saying:
There was no instance found at projects//instances/ or you are not authorized to connect to it.
I am the owner of the project, and also have Admin rights to the Cloud SQL instance. The project and instance are still there, and my app that accesses the data stored in the instances' database is working fine - therefore I know the database is also present, otherwise my app wouldn't work.
I didn't touch or change anything in the Cloud SQL instance. Suddenly, I simply can't access my database using the exact same procedure I have been using almost every day over the past year now.
I am able to access the database using a local Python script on my laptop and the Cloud SQL Proxy, but I would like to access it from the Cloud Shell again.
Any ideas on what could the problem be?
gcloud components update - update all of your installed components to the latest version
gcloud init - reinitialize gcloud shell. It performs the following setup steps:
Authorizes gcloud and other SDK tools to access Google Cloud Platform using your user account credentials, or from an account of your choosing whose credentials are already available.
It seems like there was a problem with the GCP Cloud Shell (even though there was no mention of it on the GCP error tracking page). When I logged back in today and followed the same above process everything worked well.
Looks like GCP Cloud Shell could occasionally go rouge and start producing errors. Word of advice, don't panic when this happens (like I did) and start resetting, rebooting and messing up things. Just wait a day and check back again.

GCP) How to keep jupyter session connected after disconnecting jupyter session from my local laptop?

I keep jupyter server running on GCP VM instance by tmux.
But the problem is that I wanna keep fitting my model after leaving jupyter server session from my local laptop
(eg. I turn off my laptop but jupyter session is still alive, fitting model, and I am able to re-connect that session to check status).
The only way I came up with is to use ~.py and execute $python3 fitting.py, but I wanna run and fit model on jupyter notebook to monitor avoiding adding extra code.
If there is a possible way to do so, please kindly teach me.
Thanks!
Have you considered using the Fairing library? It comes pre-installed with GCP's new AI Platform Notebooks.
This library allows you to pack up your notebook and send it off for remote execution. A new notebook will the executed content will be saved to your GCP Storage bucket. No active internet connection required once you kick of the notebook run.
You can learn how to use it by creating a new GCP AI Platform Notebook and looking at the tutorials folder inside it. You can also find additional tutorials for Fairing here

Google Cloud Shell - Cannot open shell

I am really new to Google Cloud Shell, and I accidentally closed the tab for the shell...and I cannot find it now.
I know I need to click the highlighted button at the top of the console window to activate Google Cloud Shell, but it is now grey, and no shell is presented on the page (it should be at the bottom).
Can anyone help?
I observed the same issue.
I refreshed the console page ( CTRL + F5 ) and I was able to see the 'Activate Cloud Shell' button again !!
However, if above does not resolves the issue, some tips:
From google docs Google Cloud Shell Limitations
Weekly usage: Cloud Shell also has weekly usage limits. If you reach
your usage limit, you'll need to wait until the specified time (listed
under Usage Quota, found under the three dots menu icon) before you
can use Cloud Shell again.
Also, there are usage limits on this, check your email if you had violated any conditions on shell usage:
Warning: Violating the Terms of Service will result in Cloud Shell
being disabled for your account. This constitutes activity that
adversely impacts Google Cloud Platform services, other customers' or
their end users' use of services, or the Google network used to
provide these services. Coin mining and network scanning using Cloud
Shell are strictly prohibited.
I had the same issue here.
You can install the command line interface in your terminal to access Google Cloud Datalab.
Here you will find the quickstart to configure the environment.
Installing datalab component:
gcloud components install datalab
Connecting with your VM Instance:
datalab connect *instance-name*
Opening the initial page:
http://localhost:8081
See more:
Google Cloud Datalab - Quickstart
It works now. It seems that there was a service problem earlier today, so the page was not well functioning.