Guide to connect to google colab with ssh from terminal and run jupyter lab
Google colab is a good option to experiment and try heavy computational tasks on a high end computer for free. Notebook interface provided by google is perfect ...
Google colab is a good option to experiment and try heavy computational tasks on a high end computer for free. Notebook interface provided by google is perfect python programs.
I have made a script to connect to colab instance with just few comands.
## What you need ?
1. ngrok Account
2. ssh public key
Go to [https://ngrok.com](https://ngrok.com/) and create an account and copy the authtoken only
```
./ngrok authtoken ZT64bWYnXsdTAdfdassJej4FNFT_2auAQqKqZHn2Sh4g2sfAD
```
we need only last argument of command from above.
for second option : run ssh-keygen and just press enter 3–4 times if it asks for anything
and then copy the public key
run cat .ssh/id_rsa.pub
reference is here

now open google colab, connect to desired runtime type and execute following commands in notebook cell:
! wget https://gist.githubusercontent.com/archie9211/ae3c8411da88ae8b2a05b0ee1a4fd412/raw/ee1a6e78fc498ad6d4830cd2eb6033839235ea8a/colab-ssh-jupyter.sh
!bash colab-ssh-jupyter.sh
Enter the authtoken and ssh public key when prompt asks respectively.
it will print the ssh command to connect to colab instance. e.g
ssh root@0.tcp.ngrok.io -p 16826 # it will be different for your case
Open terminal in your local pc and run the command you get on colab.
you will get a bash shell logged in to colab instance. for jupyterlab, first install following on the terminal :
pip3 install jupyterlab && apt