colab miscellaneous utils
Project description
colab miscellaneous utils ![Codacy Badge](https://pypi-camo.freetls.fastly.net/878ce5bf7381554aa5c098a65a438d2dbd4c59d5/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3833623762326362336164653435383938313239313766313837613861626162)
![Code style: black](https://pypi-camo.freetls.fastly.net/fbfdc7754183ecf079bc71ddeabaf88f6cbc5c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d626c61636b2d3030303030302e737667)
![License: MIT](https://pypi-camo.freetls.fastly.net/8645b002dd7ec1b54275a80574942e7a318e03c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)
![PyPI version](https://pypi-camo.freetls.fastly.net/248d261c1a316ec5579bae3a7afd6df7eb5de864/68747470733a2f2f62616467652e667572792e696f2f70792f636c6d7574696c732e737667)
Miscellaneous utils mainly intended for use in colab
Demo: notebooks in Colab
git push
from Colab
Set up a reverse ssh tunnel for ssh to Colab VM
in English (I may provide a Chinese version later)
Installation
pip install clmutils # clm: colab-misc
Usage
Write a private key to ~/.ssh/gh-key
from clmutils import create_file
gh_key = \
"""
-----BEGIN EC PRIVATE KEY-----
MH.............................................................9
AwEHoUQDQgAEoLlGQRzIVHYw3gvC/QFw3Ru45zGawaBaCq6jTqdyH2Kp8zIB3TdJ
K9ztlJBRRAOHh5sPhQ4QpdZH1v1rWeDWIQ==
-----END EC PRIVATE KEY-----
""".strip() + "\n"
# Do not remove .strip() + "\n"
# the private key is very picky about format
create_file(gh_key, dest="~/.ssh/gh-key")
Set up github.com
config for git push
from clmutils import append_content
config_github_entry = \
"""
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh-key
"""
append_content(config_github_entry, dest="~/.ssh/config")
Verify that everything is OK, from a cell
!ssh -o StrictHostKeyChecking=no -T git@github.com
If you see something similar to
Hi your-name! You've successfully authenticated, but GitHub does not provide shell access.
you are good to go.
You can now set up git config global
from a cell, e.g.
!git config --global user.email your-email-address
!git config --global user.name your-github-username
# !ssh-keyscan github.com >> ~/.ssh/known_hosts
You are ready to clone your own repo, run your app and generate new data, update the repo and push to github
.
Utils planned
-
:white_check_mark:
create_file
creates a file with given mode, e.g. for.ssh/id_rsa
orIdentityFile
in.ssh/config
-
:white_check_mark:
apppend_content
appends some content to a file, e.g., for appended a public key to.ssh/authorized_keys
-
:white_check_mark:
chmod600
chmod
of a file -
reverse_ssh_tunnel
sets up a reverse ssh tunnel to a remote host with via autossh -
More
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.