Skip to main content

Colab SSH

Create SSH tunel to a running colab notebook

PyPI version Downloads build_status codecov license

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

Metadata

Release files for linus-colab-ssh 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linus-colab-ssh 0.1.6
File Size Uploaded Provenance Actions
linus_colab_ssh-0.1.6.tar.gz 11.6 kB Without provenance Details for linus_colab_ssh-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linus-colab-ssh 0.1.6
File Interpreter ABI Platform Actions
linus_colab_ssh-0.1.6-py3-none-any.whl Python 3 none any Details for linus_colab_ssh-0.1.6-py3-none-any.whl

Total release size: 24.4 kB

Release files / linus_colab_ssh-0.1.6.tar.gz

Download URL linus_colab_ssh-0.1.6.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
640d1f21a9f1f461ec1765e24a01ed721b044adddd0c30996031d64b0d29ca36
BLAKE2b-256 checksum
How to use checksums
2c482848ad99afbc48b7fcb05508e10c2c233f733efb27769d48475293038a96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / linus_colab_ssh-0.1.6-py3-none-any.whl

Download URL linus_colab_ssh-0.1.6-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbd4788fddf0577468aa4c1b4e45c24fded1900b73540583e80e66a1767033bb
BLAKE2b-256 checksum
How to use checksums
6b71c00498460b6dc68331ba2ee94ca55a810483a5052d4e5e0bdfa68d6fe2a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Security for linus-colab-ssh 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page