Skip to main content

Google colab SSH connector

Project description

Google Colab-ssh

Connect to Google colab via ssh easily

What is Colab-ssh

Colab-ssh is a light-weight library that enables you to connect to a Google Colab virtual machine using an SSH tunnel.

User interface is still required in order to create the Colab virtual machine

Installation

To install Colab-ssh library, you need to run this command

pip install colab_ssh --upgrade --user

Getting started

  1. Open Google Colab and run this code in one of the code cells
# Install colab_ssh
!pip install colab_ssh --upgrade

from colab_ssh import launch_ssh, init_git
launch_ssh(ngrokToken,password)

# Optional: if you want to clone a github repository
init_git(githubUrl)
  • password is your ssh password that you want to choose
  • ngrokToken is your ngrok token that you can get from here
  • githubUrl is your github HTTPS clone url (usually ends with .git)

Avoiding passwords

Instead of setting a password, you can access the SSH tunnel using your own pair of keys.

IMPORTANT: For this to work you need to setup your git repository by using the function git_init()

How it works ? : We get your public key from the repository passed into the git_init() function and then we add it to the authorized_keys file (found in ~/.ssh folder).

You need to follow these steps:

  1. Create a pair of SSH key
  2. Copy your public key (should be inside the file id_rsa.pub)
  3. In the root of your github repository, create a folder called .colab_ssh and a file within it called authorized_keys
  4. Paste your public key inside the file .collab_ssh/authorized_keys

Using VSCode to connect Google Colab

Once you run the code in the Getting Started section you will notice a message like this

...
Successfully running tcp://0.tcp.ngrok.io:XXXX
...
  • XXXX is the port provided by ngrok

You can now open VSCode and add this to your SSH Configuration

Host google_colab_ssh
  HostName 0.tcp.ngrok.io
  User root
  Port XXXX

Make sure you replace XXXX with the port you just obtained

Then connect to the remote google_colab_ssh.

Contribution

Well for now, try to discover things yourself.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colab_ssh-0.2.51.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colab_ssh-0.2.51-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file colab_ssh-0.2.51.tar.gz.

File metadata

  • Download URL: colab_ssh-0.2.51.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for colab_ssh-0.2.51.tar.gz
Algorithm Hash digest
SHA256 292a0189f2d2c4a1855ff53d665d50ae4cdd6664a778942e36c4612664766891
MD5 4eb2d57e7b0739bc6b298798d5048d34
BLAKE2b-256 3fa5d4bb459d6042d5f1e3e35559b9b2ad8cec1ba17b97f4de63a028853b31d6

See more details on using hashes here.

File details

Details for the file colab_ssh-0.2.51-py3-none-any.whl.

File metadata

  • Download URL: colab_ssh-0.2.51-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for colab_ssh-0.2.51-py3-none-any.whl
Algorithm Hash digest
SHA256 503fd5a9fb5287b8d652679100d50d3d67f6a06a5bb6c5b4d4a40bb6a58b55c5
MD5 c922fd126306357bc421965c08f19236
BLAKE2b-256 41bf1572a429455398f740954f8cbb99a59527d714d350b32022e3882c081f61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page