articleswikiproducts
RSS feed
contact
articleswikiproducts
RSS feed
contact
articleswiki
products

Made by nerdfish, development with user experience in mind.

Github
All wiki

setting up ssh keys for github and bitbucket

25 May 2022

Generating a new SSH key for GitHub

Basic ssh key adding

Generating a new SSH key for GitHub.

Paste the following into GitHub:

Add the SSH key locally.

If you use a new host or something like `bitbucket.org-clientname` as `host`, you need to add it to your ssh.

Config file

If there is no config file yet:

Once there is a config file, you can add configurations with the following:

Multiple accounts by the same host

Sometimes you have different accounts (work, private, client 1, client 2, ...), and you want to ensure you commit with the proper credentials.

You can do that, but it requires a bit of work. It works the same way you add a regular ssh-key, but there are some differences.

Paste the following into your host (Bitbucket in this example):

Now is where it gets different. You create an alias. We can add anything we want behind the hostname. In this example, we add "-private", but it might as well be "-client-x".

In the config, we resolve the hostname.

ssh-keygen -t ed25519 -C "<insert email>" -f ~/.ssh/github
ssh-add -K ~/.ssh/github
pbcopy < ~/.ssh/github.pub
ssh -T git@bitbucket.org-clientname
ssh -T git@bitbucket.org-clientname
touch ~/.ssh/config
printf "# Github\n Host github.com\n Hostname github.com\n AddKeysToAgent yes\n UseKeychain yes\n IdentityFile ~/.ssh/github" | tee ~/.ssh/config
ssh-keygen -t ed25519 -C "<insert email>" -f ~/.ssh/bitbucket-private
ssh-add -K ~/.ssh/bitbucket-private
pbcopy < ~/.ssh/bitbucket-private.pub
ssh -T git@bitbucket.org-private
printf "# Bitbucket private\n Host bitbucket.org-private\n Hostname bitbucket.org\n AddKeysToAgent yes\n UseKeychain yes\n IdentityFile ~/.ssh/bitbucket-private" | tee ~/.ssh/config