You can set up Multiple GitHub accounts on a single device using SSH key
Having to maintain multiple GitHub accounts for your projects might be time-consuming. Or GitHub SSH key setup is time-consuming for us. When we clone a new repository from a particular account that does not have access to the private repository, it is a little difficult for beginners like me to figure out.
Consider that you have two different GitHub profiles, such as “email@example.com” and “firstname.lastname@example.org.” An SSH key setup can assist you if you wish to copy a private repository from Account1 that won’t be accessible from Account2.
Alternatively, if you belong to a private organization and experience issues like this:
Initialized empty Git repository in `/Users/username/Documents/Repo/YourRepo.git/` Permission denied (publickey). fatal: The remote end hung up unexpectedly
SSH key setup is a must!
That is also very simple to accomplish. We’ll set up the SSH key on our local machine in five minutes.
Table of content
SSH key Setup started
Step 1: Check the existing key
Open the terminal on the root directory
You can check available SSH setups as well by command
If there is no .ssh file present, run this command:
ssh-keygen -t rsa
Then press the return key to complete the setup.
If you already have some key setup, then you will get like this
You can update those or create a new SSH key to config.
Step 2: Setup a new key
create a new key with this command
ssh-keygen -f user_id_1
You may use anything to identify your account as the ‘user id 1’ in this case refers to your SSH key. After creating new SSH, you can check by command
ls , and then it will show like
There will be a public key to use. Generate the SSH key by this command
It will generate a long SSH key, copy from the beginning to
= (equal sign). For example SSH key will look alike
3. Save the key to GitHub
Go to your GitHub account and then settings >> create a new SSH key, paste copied SSH key. You can follow the settings page: https://github.com/settings/keys
4. Config the account on the local machine
back to the terminal again and set up a config file. First, create a config file by
Then open the config file and write the host, hostname, and identifier like this. You can copy the code below and replace the user_id_1 part with your SSH key name.
Congratulations, Your SSH key setup is done.
Multiple GitHub SSH (account) setup:
You must create more SSH keys for multiple accounts using the same process. Create a new SSH by the command below.
ssh-keygen -f user_id_2
Then generate a new key by
To create a new SSH using the generated id, copy the SSH key and proceed to your GitHub settings. Follow step 3
Back to the terminal and setup the config file for another account by writing the config file
Save the file before exiting! All done 🥳
Manage multiple account access:
You can clone by ssh from GitHub using Account 1 and Account 2 like this
copy the SSH URL, then clone from account 1:
git clone email@example.com:hasanuzzamanbe/php-environment-setup-for-mac.git (Nothing changed for account 1)
From account 2:
git clone firstname.lastname@example.org- Just add the host before the repository name here
account2 is the host slug.
Your SSH setup for GitHub is done! You can set up more accounts following this procedure as well.
If you have any trouble setting up the PHP environment on your Mac or if you want to install WordPress locally. You can follow this article as well