I have changed only two directory names from the original post to be found here
Open account with ngrok.com
Get the autorization code
after creating a free account with ngork
. You will meet with a screen like following
In you colab do the following. replace authorization code
with what you would get in ngrok website.
Change password
with any password you want.
# Install useful stuff
! apt install --yes ssh screen nano htop ranger git > /dev/null
# SSH setting
! echo "root:password" | chpasswd
! echo "PasswordAuthentication yes" > /etc/ssh/sshd_config
! echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
! echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
! service ssh restart > /dev/null
# Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
# Run ngrok
authtoken = `authorization code`
In case you error here, in most of the cases that's the port number you need to change
get_ipython().system_raw('./ngrok authtoken $authtoken && ./ngrok tcp 22 &')
! sleep 3
# Get the address for SSH
import requests
from re import sub
r = requests.get('http://localhost:4040/api/tunnels')
str_ssh = r.json()['tunnels'][0]['public_url']
str_ssh = sub("tcp://", "", str_ssh)
str_ssh = sub(":", " -p ", str_ssh)
str_ssh = "ssh root@" + str_ssh
print(str_ssh)
You will see something like the follwoing
ssh [email protected] -p 11781
This step will need to you to log in with your google account in order to get an API key
from google.colab import drive
drive.mount('/googledrive')
If you get error with the following step then you have to delete already existing directories in /root/.local/share/
of your
ngrok server
! mkdir -p /googledrive/MyDrive/colabdrive
! mkdir -p /googledrive/MyDrive/colabdrive/root/.local/share/code-server
! ln -s /googledrive/MyDrive/colabdrive /
! ln -s /googledrive/MyDrive/colabdrive/root/.local/share/code-server /root/.local/share/
Run the following in terminal of google colab (you have click on the terminal tab)
curl -fsSL https://code-server.dev/install.sh | sh > /dev/null
code-server --bind-addr 127.0.0.1:9999 --auth none &
ssh -N -f -L localhost:9999:localhost:9999 [email protected] -p 11781