Create SSH tunel to a running colab notebook
Project description
Colab SSH
Create SSH tunel to a running colab notebook
Prerequisite
- This package only allow SSH public key authentication so you will need to prepare once. You might already had one at
~/.ssh/id_rsa.pub
. Refer this to create a new one if you don't had once already - In order to connect to the SSH tunel from your machine, you will need to install
cloudflared
from here
Usage
Create a new Colab notebook with a single cell with the following content:
!pip3 install linus-colab-ssh
from colab_ssh import setup_ssh, loop_forever
public_key = '<YOUR_PUBLIC_SSH_KEY>'
setup_ssh(public_key)
loop_forever()
You can use list of public key or link to a raw text file of authorized_keys
like this as well
Optinally, you can also specify a Mattermost Webhook URL with mattermost_webhook_address
when calling setup_ssh
to send a push notification to your Mattermost channel when the SSH tunel is ready.
Run it, after about 2 minutes, you will see something like this:
Command to connect to the ssh server:
✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️
ssh -o UserKnownHostsFile=/dev/null -o VisualHostKey=yes -oProxyCommand="cloudflared access ssh --hostname %h" root@economic-singapore-place-obtaining.trycloudflare.com
✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️
Or you can use the following configuration in your .ssh/config file:
✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️
Host colab
HostName economic-singapore-place-obtaining.trycloudflare.com
User root
UserKnownHostsFile /dev/null
VisualHostKey yes
StrictHostKeyChecking no
ProxyCommand cloudflared access ssh --hostname %h
✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️✂️```
Then voila ;)
Please noted that you must keep the kernel webpage connected to avoid Colab disconnect your kernel early.
Disclaimer
This repo contains many of the configuration that I use for my day to day work so it might not be the best for you.
If you had any problems using this, feel free to open an issue. Otherwise, I highly recommend you to fork this repo and did some necessary modification for yourself. Thanks for checking by
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for linus_colab_ssh-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbd4788fddf0577468aa4c1b4e45c24fded1900b73540583e80e66a1767033bb |
|
MD5 | 14bb9f66ca6df7acd929d1bb045d20d2 |
|
BLAKE2b-256 | 6b71c00498460b6dc68331ba2ee94ca55a810483a5052d4e5e0bdfa68d6fe2a8 |