How to Work with GitHub and Multiple Accounts

Step 1 – Create a New SSH Key

We need to generate a unique SSH key for our second GitHub account.

ssh-keygen -t rsa -C "your-email-address"

Be careful that you don’t over-write your existing key for your personal account. Instead, when prompted, save the file as id_rsa_COMPANY. In my case, I’ve saved the file to ~/.ssh/id_rsa_work.

Step 2 – Attach the New Key

Next, login to your second GitHub account, browse to “Account Overview” and attach the new key, within the “SSH Public Keys” section. To retrieve the value of the key that you just created, return to the Terminal and type: vim ~/.ssh/id_rsa_COMPANY.pub.

Copy the entire string that is displayed, and paste this into the GitHub textarea. Feel free to give it any title you wish.

Next, because we saved our key with a unique name, we need to tell SSH about it. Within the Terminal, type: ssh-add ~/.ssh/id_rsa_COMPANY. If successful, you’ll see a response of Identity Added.

Step 3 – Create a Config File

We’ve done the bulk of the workload; but now we need a way to specify when we wish to push to our personal account, and when we should instead push to our company account. To do so, let’s create a config file.

touch ~/.ssh/config vim config

If you’re not comfortable with Vim, feel free to open it within any editor of your choice. Paste in the following snippet.

Default GitHub


	Host github.com
	  HostName github.com
	  User git
	  IdentityFile ~/.ssh/id_rsa

This is the default setup for pushing to our personal GitHub account. Notice that we’re able to attach an identity file to the host. Let’s add another one for the company account. Directly below the code above, add:

	Host github-COMPANY
	  HostName github.com
	  User git
	  IdentityFile ~/.ssh/id_rsa_COMPANY

This time, rather than setting the host to github.com, we’ve named it as github-COMPANY. The difference is that we’re now attaching the new identity file that we created previously: id_rsa_COMPANY. Save the page and exit!

Step 4 – Try it Out

It’s time to see if our efforts were successful. Create a test directory, initialize git, and create your first commit.

	git init
	git commit -am "first commit'

Login to your company account, create a new repository, give it a name of “Test,” and then return to the Terminal and push your git repo to GitHub.

	git remote add origin git@github-COMPANY:Company/testing.git
	git push origin master

Note that, this time, rather than pushing to git@github.com, we’re using the custom host that we create in the config file: git@github-COMPANY.

Return to GitHub, and you should now see your repository. Remember:

When pushing to your personal account, proceed as you always have. For your company account, make sure that you use git!github-COMPANY as the host.

美國銀行開戶(二) – TD Bank

在 Citibank 開完帳戶後,因為剛好遇到下雪,看來暫時不會這麼快停,沒有辦法出外走動,想到剛剛在 Citibank 沒有開 Savings Account, 剛好看到在附近還有一家 TD Bank, 因為銀行宣稱 24/7 每天 24 小時都有營業,同時也自稱是 America’s Most Convient Bank 感覺蠻方便的, 所以就走進去再開另一個銀行帳戶備用,同時也可以避開大雪。因為先前有在 TDAmeritrade 開證券戶,所以對貌似同集團來自加拿大的 TD Bank 頗有好感。

TD Bank 沒有單一櫃台,一進入銀行就有一個華裔男行員 R 來招待。先用英文表明要開戶後,就被帶到他的位置,我先詢問是否可以用中文(Mandarin) 溝通,他表示他不會說中文,如果要說中文要等他另一個同事有空。在我表示無妨,同意用英文溝通開戶後,就開始進行開戶。

Read more

美國銀行開戶(一) – Citibank NYC

趁著這次在紐約停留之餘,到位於 Chinatown 的 Citibank Canal St 分行進行開戶。

Citibank Address : 164 CANAL ST. NEW YORK, NY 10013

其實本來是想在CHASE開戶的, 半年前在紐約時,並不知道 CHASE 是如今的大魔王,沒有美國當地 Utility bill 的新戶很難開戶,當時沒什麼準備直接 Walk in 一間分行表明要開戶,結果就直接被拒絕了。因為當時也沒什麼緊急需求,加上出差時間不多,就沒再嘗試了。

這次因為美國證券投資的部位變大,為了未來方便資金的流動,所以很認真地把開戶的相關資料準備齊全,再到Citibank NYC Canal St 分行開戶。

Read more