$ ssh-keygen -t rsa -C "hong@hongfs.cn" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/test1 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/test1. Your public key has been saved in /root/.ssh/test1.pub. $ ssh-keygen -t rsa -C "hong@hongfs.cn" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/test2 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/test2. Your public key has been saved in /root/.ssh/test2.pub.
创建完成后把 public key 文件内容添加到 GitHub 相应项目的 Deploy keys。
$ git clone git@test1.github.com:hongfs/test1.git Cloning into 'test1'... The authenticity of host 'github.com (140.82.113.3)' can't be established. RSA key fingerprint is SHA256:nThbg7kXUpJWGl7E1IGOCspRomTxdCARLviKw1E5SY8. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com,140.82.113.3' (RSA) to the list of known hosts. remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
第二个项目 clone
1 2 3 4 5 6 7
$ git clone git@test2.github.com:hongfs/test2.git Cloning into 'test2'... Warning: Permanently added the RSA host key for IP address '140.82.112.3' to the list of known hosts. remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done.
第一个项目 pull
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ cd test1 $ git pull Warning: Permanently added the RSA host key for IP address '140.82.113.4' to the list of known hosts. remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From test1.github.com:hongfs/test1 31861d1..936c437 master -> origin/master Updating 31861d1..936c437 Fast-forward README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md