index 日本語

Internet of Tomohiro

If you found my articles interesting or useful, please donate using following links:

How to access Google Colaboratory using ssh

2022/9/15: Using a remote desktop or SSH is now disallowed from Colab runtimes

You can also use desktop environment on Google Colaboratory using VNC.



More details of this procedure:

If you have questions:

  1. Sign up for ngrok
  2. Copy & paste setup code
  3. Click run bottom in top left
  4. Copy ngrok authtoken
  5. Select ngrok region

    Probably the region closest to you is fastest.

  6. Wait for starting SSH server
  7. Login to the server

How it works

You can run not only python code but also bash commands on Google Colaboratory. These commands are executed as root. You can install any packages with apt or pip. And you can even download any file with wget and run it. So you can easily install openssh and run sshd. It use ngrok so that you can login to the ssh server because you cannot login to it through the internet just by running sshd. But there are large latency because all communication between the server and the client go through the ngrok server.

【Optional】Install Nim

Install Nim language that is faster and more elegant than python. Execute following command:

$ curl -sSf | sh

After installing you asked to copy

export PATH=/home/colab/.nimble/bin:$PATH

to ~/.bashrc .

Then you can use Nim. yay!

$ echo "echo \"Hello Nim!\"" > hello.nim
$ nim c -r hello.nim

by Tomohiro