Preface:
I recently switch from bluehost to hostgator because my bluehost account is expired after using it for three years. Its renewal price is $250, but creating a hostgator account is only for about $170. Another thing is I am not going to recover the old posts since I haven’t updated them for a long time, but from now on, I will keep updating this blog.
Start:
Let’s assume we have two repositories in our github account:
git@github.com:james/one.git
git@github.com:james/two.git
We need to create SSH keys for our repositories:
$ ssh-keygen -f ~/.ssh/id_rsa.github.james.one
$ ssh-keygen -f ~/.ssh/id_rsa.github.james.two
Then, it will ask us if we want to set the password for our keys; press enter means no password. After this step, we will get the public key and private key.
Using unix copy commend pbcopy < id_rsa.github.james.one.pub
to copy the public key, then add and paste it into our repository one’s deploy key. Do the same thing to repository two as repository one.
In local $ ~/.ssh/
, we do $ touch config
. In the config
file, we add the following:
1 |
|
Note: normally, original git url is: git@github.com:James/one.git
, after we setup the config file, now it becomes: git@github.com-one:James/one.git
.
When we clone these two repositories into one single folder, inside folder, we need to check if there are keys by using $ ssh-add -l
If there are keys, we need to delete them by using $ ssh-add -D
.
Clone the repository one using $ git clone git@github-one.com:James/one.git
, similarlly, we clone repository two using $ git clone git@github.com-two:James/two.git
.
Important: we need to do step 4 inside these two repositories folders. And in the corresponding folder (repositories), we add our private keys. For example, in repository one, we do $ ssh-add ~/.ssh/id_rsa.github.James.one
.