Colab用ssh登陆Github

Note: Remove ! when not using colab.

!git config --global user.email <email>
!git config --global user.name <name>
!ssh-keygen -t rsa -b 4096 -C “<user-name>@github.com”
!cat "/content/drive/My Drive/projects/.ssh/id_rsa.pub"  
# usually, this dir should be ~/.ssh/, but colab would clear /root/.ssh/ for restarting the colab,so we will copy this dir to /root/ each time. Also, add the public key to Github SSH key after this step.
!ssh-keyscan github.com >> "/content/drive/My Drive/projects/.ssh/known_hosts"
!chmod 644 "/content/drive/My Drive/projects/.ssh/known_hosts"
!cp -r "/content/drive/My Drive/projects/.ssh/" "/root/"
!ssh -T git@github.com

The last output should be:

Warning: Permanently added the RSA host key for IP address '52.69.186.44' to the list of known hosts.
Hi xDarkLemon! You've successfully authenticated, but GitHub does not provide shell access.
上一篇:其它/编程 删除合同段SQL


下一篇:IDEA Cannot Resolve Symbol 问题的解决方法汇总