Last active
January 23, 2021 06:22
-
-
Save p-geon/75523f5de4a571cecf35b124aa319474 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Before running this cell, you will set hidden vars by "add-ons" menu. | |
""" | |
from kaggle_secrets import UserSecretsClient | |
def clone_repository( | |
ssh_keyval: "str: BEGIN RSA PRIVATE KEY to END RSA PRIVATE KEY" | |
, ssh_keyname: "str: id_rsa..." | |
, gitrepo: "str: your private repository to clone" | |
, uname_git: "str: username of your Git") -> None: | |
""" | |
receive hidden vars, then clone private repository to "/kaggle/working/" | |
""" | |
ssh_command = f"ssh -l {uname_git} -i /kaggle/working/{ssh_keyname} -o StrictHostKeyChecking=no -F /dev/null" | |
!rm -rf /kaggle/working/$gitrepo | |
!echo $ssh_keyval> $ssh_keyname | |
!chmod 600 /kaggle/working/$ssh_keyname | |
!git -c core.sshCommand="$ssh_command" clone git@github.com:$uname_git/$gitrepo | |
!rm /kaggle/working/$ssh_keyname | |
us = UserSecretsClient() | |
clone_repository(ssh_keyval=us.get_secret("ssh_keyval"), ssh_keyname=us.get_secret("ssh_keyname") | |
, gitrepo=us.get_secret("gitrepo"), uname_git=us.get_secret("uname_git")) | |
del us |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment