colab通过ssh连接github

命令如下:

!git config --global user.email "email"
!git config --global user.name "username"
#!ssh-keygen -t rsa -b 4096 -C “<user-name>@github.com”
!cat /content/drive/MyDrive/myfile/colab_ssh/.ssh/id_rsa.pub #填入github的
!ssh-keyscan github.com >> "/content/drive/MyDrive/myfile/colab_ssh/.ssh/known_hosts"
!ssh-keyscan github.com >> "/root/.ssh/known_hosts"
!chmod 644 "/content/drive/MyDrive/myfile/colab_ssh/.ssh/known_hosts"
!cp -r "/content/drive/MyDrive/myfile/colab_ssh/.ssh/" "/root/"

测试是否连接:

!ssh -T [email protected]
!ssh -vT [email protected]

输出:

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.

表示连接成功

当从github clone repo的时候,要用ssh方式进行clone而非https方式。

猜你喜欢

转载自blog.csdn.net/yangtuoi/article/details/118424296
今日推荐