Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why google cloud shell auto disconnect after 1 hours

Tags:

I use Google Cloud Shell to run Jupyter Notebook on instance , but after 1 hours,the connection is disconnect.

And I reconnect to instance, there is nothing, is same as reset instance.

So, please tell me how to set up ,make the connection of cloud shell keep connect.

Thanks!

like image 400
hiyoung liu Avatar asked Apr 23 '18 08:04

hiyoung liu


People also ask

How do I stop Google Cloud Shell from disconnecting?

Disable Cloud Shell for managed user accounts This can be done by going to the Google Admin console and then navigating to Apps > Additional Google services > Google Cloud Platform > Cloud Shell Settings and disabling "Cloud Shell Access Settings".

How long does Google Cloud Shell last?

Cloud Shell is intended for interactive use only. Non-interactive sessions are ended automatically after one hour. Cloud Shell sessions are capped at 12 hours, after which sessions automatically terminate. You can start a new session immediately after.

How do I keep Google Cloud Shell alive?

Google cloud has a session timeout across the board of 10 minutes, so you need to use a keepalive . Try adding the argument --ssh-flag="-ServerAliveInterval=30" - any value less than 600 should do the trick there. There's a description of the timeout here, and full usage details for gcloud ssh here. Save this answer.

Is Google Cloud Shell always on?

With Cloud Shell, the Cloud SDK gcloud command and other utilities you need are always available when you need them. In this codelab, you will learn how to connect to computing resources hosted on Google Cloud Platform via the web.


1 Answers

Google Cloud Shell auto disconnect because you didn't do anything in the Cloudshell's terminal! So to keep the cloudshell session alive, you can enter the following javascript code to the browser's javascript console

setInterval(function() {document.elementFromPoint(500, 500).click();}, 30000);

That's the trick!

P/S: If you want to use Jupyter Notebook, why you don't use Google Colab instead? It has a pre-installed Jupyter Notebook as well as more CPU and ram. You can use the same js for Colab!

UPDATE: you can try Cloud Shell SDK, then connect to Google Cloud Shell by gcloud cloud-shell ssh, which is much faster than the web interface, allow port forwarding (based on ssh), and have a longer time limit.

You can even connect to it using VSCode.

like image 138
raspiduino Avatar answered Sep 28 '22 18:09

raspiduino