by Devin Yang
(This article was automatically translated.)

Published - 4 years ago ( Updated - 4 years ago )

There seem to be many colab ssh introductions on the Internet.
Here I introduce, I use my own connection method to connect to colab through the bash I wrote.

How to do it is conceptually simple,

This bash will install OpenSSH Server on the VM of colab,
And randomly generate your own OpenSSH public key pairs (SSH key pairs).

Then, through this bash, we also provide him with the connection information of our own host,
The host's "user name", "host location" and "port to establish ssh channel", and our own "OpenSSH public key".

This bash can add the public key we provided to colab's /root/.ssh/authorized_keys,
Let's gain access to the colab root VM.

Then on the colab vm, it will also provide us with a random generated public key (/root/.ssh/authorized_keys),
Add it to ${HOME}/.ssh/authorzed_keys of our host, so that colab has permission to connect to our host,

So this Bash executed on Colab can help us establish an SSH channel between the VM and our host.

When the encrypted channel is established, we can penetrate the firewall,
Log in to the VM of colab.



Check out the demo.

A free GPU is great for running Python. : D
My colab_ssh Github.

Note: If you are disconnected and using the same port, you may need to delete the old channel, or switch to a different port.
You can also use clear_all_tunnels.sh in GitHub to clear all useless connections in your computer Wire.