Pre Requisite
Github account
Scispot account with JupyterHub enabled
Scispot account with Github integration enabled
Some linux terminal command knowledge (Optional)
Functionality
Customers with JupyterHub access have the option to sync scripts stored in JupyterHub with a Github repository
This article will go through setting up the SSH authentication for Github as well as using the Git GUI extension for JupyterLab, but using the terminal to run git commands is also supported for more advanced Git usage
Steps to Sync Jupyter Hub with a Github Repo
We will first configure the ssh key for github authentication. First login to your jupyterlab and click on the terminal
Run the following commands in the terminal by copying and pasting:
This will remove any previously created ssh keys
rm -r .ssh
You may receive an error if the folder doesn't exist, you can safely ignore this error:
rm: cannot remove '.ssh': No such file or directory
Now create the ssh directorymkdir -p ~/.ssh
Set permission on the newly created directory
chmod 700 ~/.ssh
Generate the ssh public and private key
ssh-keygen -t ed25519 -C "scispot_jupyter_ssh" -f ~/.ssh/id_ed25519
You will receive the following, passphrase is optional, simply type the passphrase you would like to use (or leave it blank) and press enter for each line
Generating public/private ed25519 key pair.Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/jovyan/.ssh/id_ed25519
Your public key has been saved in /home/jovyan/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:RsB9WiVJSdCCWCJvQZy3kkq5NHnJD1NFsCr188InlHQ scispot_jupyter_ssh
The key's randomart image is:
+--[ED25519 256]--+
| .o+=+*+=++. |
| o+o=oo *. |
| ++=o.E= |
| *oO+.+. |
| o.=.== S |
| o. o.+ |
| + o |
| + |
| |
+----[SHA256]-----+Set permissions on the ssh public and private key
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
Add github to known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
Set permissions on known_hosts
chmod 644 ~/.ssh/known_hosts
Reveal the public key and copy the ENTIRE SSH key displayed in the console
cat ~/.ssh/id_ed25519.pub
This is what the response will look like that you would need to copy
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILQNgvhF0wGnrsQlSgOOvPgCwwvG5Z9zlSLc7hbTYuWa scispot_jupyter_ssh
Once setup, go click on "Code" and switch to the "SSH" tab. Copy the SSH URL.
Now swap to JupyterLab and open up the terminal
In the terminal type "git clone " and paste (hotkey: shift + ins) the SSH URL you've copied earlier
This will clone the Github repo into a new folder, in this example it is the scispot-jupyterlab-scripts folder. Navigate to this folder then click on the Git extension tab on the left to open up the Git GUI.
Using Git in JupyterLab
Now after making some changes we can click this "+" button to stage our changes, add a commit message and then commit the change
If it's your first time commiting, you'll be prompted to add a name and email for this commit. This will be saved for any subsequent commit, but can be changed using Git commands
Now after commiting we can then click on this button to push to remote
You should then receive a notification on the bottom right of your screen with a success message.
Checking on Github you will then see the user that was setup from before pushing changes