Web Development

How to Use More Than One GitLab Account Using One Window’s Device

7 mins | Dec 30, 2024

How to Use More Than One GitLab Account Using One Window’s Device

Managing multiple GitLab accounts on a single computer can be challenging, especially if you want to keep work and personal projects separate. Here’s a step-by-step guide on how to set up two accounts on a Windows device, using SSH keys for each. I’ll also cover some common errors and troubleshooting tips.

Step 1: Create SSH Keys for Each Account

You’ll need two SSH keys: one for your personal account and one for your work account.

1. Open Git Bash on Windows.

2. Generate a key for your personal account:

ssh-keygen -t rsa -C "your-personal-email@example.com" -f C:\Users\tantr\.ssh\id_rsa_personal

This command creates an SSH key pair (private and public) for your personal GitLab account. Leave the passphrase blank if you don’t need extra security

3. Generate a key for your work account:

ssh-keygen -t rsa -C "your-work-email@example.com" -f C:\Users\tantr\.ssh\id_rsa_work

After these steps, you should have two sets of SSH keys in the .ssh directory:

  • id_rsa_personal and id_rsa_personal.pub
  • id_rsa_work and id_rsa_work.pub

Common Error: “Saving key ‘C:\Users\tantr.ssh\id_rsa_personal’ failed: No such file or directory”

If you encounter this error, the directory does not exist. Create it with:

mkdir -p C:\Users\tantr\.ssh

Then, re-run the key generation commands above.

Step 2: Adding SSH Keys to Your GitLab Accounts

After generating your SSH keys, you’ll need to add them to your GitLab accounts.

1. Copy the public key for your personal account:

cat C:\Users\tantr\.ssh\id_rsa_personal.pub

2. Go to GitLab, log in to your personal account, navigate to Settings > SSH Keys, paste the public key, and save.

3. Repeat for the work account:

cat C:\Users\tantr\.ssh\id_rsa_work.pub

4. Log in to your work GitLab account, go to Settings > SSH Keys, paste the public key for your work account, and save.

Step 3: Configure SSH to Distinguish Between Accounts

Now that both accounts are configured on GitLab, you need to set up SSH to know which key to use for each account.

1. Open or create the SSH configuration file:

notepad C:\Users\tantr\.ssh\config

2. Add the following configuration:

# Personal GitLab account
Host gitlab-personal
    HostName gitlab.com
    User git
    IdentityFile C:\Users\tantr\.ssh\id_rsa_personal

# Work GitLab account
Host gitlab-work
    HostName gitlab.com
    User git
    IdentityFile C:\Users\tantr\.ssh\id_rsa_work

This configuration creates aliases (gitlab-personal and gitlab-work) so SSH can identify the appropriate key for each account.

Common Error: “Could not resolve hostname gitlab-personal”

If you see this error:

  • Confirm the config file is saved as config (not config.txt).
  • Make sure the config file is in C:\Users\tantr\.ssh.

If both are correct, restart Git Bash or Command Prompt to refresh the SSH configuration.

Step 4: Update Git Remotes to Use SSH Aliases

Now that SSH is set up to recognize both accounts, update your Git repositories to use the aliases.

1. For personal projects, set the remote to use gitlab-personal:

git remote set-url origin git@gitlab-personal:username/personal-repo.git

2. For work projects, set the remote to use gitlab-work:

git remote set-url origin git@gitlab-work:username/work-repo.git

Step 5: Test Your Setup

Finally, test to ensure everything works correctly.

1. Check the connection for each alias:

ssh -T git@gitlab-personal

You should see a message confirming that you’re authenticated with your personal GitLab account.

ssh -T git@gitlab-work

You should see a message confirming that you’re authenticated with your work account.

Common Error: “Permission denied (publickey)”

If you encounter this error:

  • Ensure that the correct SSH key is specified in the config file for each alias.
  • Make sure the public key has been added to the appropriate GitLab account.

Conclusion

Now, you can seamlessly switch between your personal and work GitLab accounts on the same Windows machine without needing to log in and out or manually switch SSH keys each time. Keeping separate keys for different accounts is a great practice to stay organized and secure while managing various projects.

Author

Akhilkumar Jaiswar
Akhilkumar Jaiswar
Junior Software Solution Engineer

Share

Share

Related

Web Development Strategies Every Developer Must Use
Web Development

Web Development Strategies Every Developer Must Use

5 mins : Sep 05, 2023

Web Development & Design Company in Dubai
Web Development

Web Development & Design Company in Dubai

5 mins : Nov 09, 2023

Boost Your Web Development Skills with These Free Online Code Editors
Web Development

Boost Your Web Development Skills with These Free Online Code Editors

6 mins : Sep 18, 2023

Other Articles

7 Best Web Application Development Software for Developers in 2024
Web Development

7 Best Web Application Development Software for Developers in 2024

6 mins : Sep 18, 2023

14 Web Development Trends You Must Watch Out In 2025
Web Development

14 Web Development Trends You Must Watch Out In 2025

5 mins : Jan 08, 2024

The AI Advantage: How AI can be used to revolutionize website development
Web Development

The AI Advantage: How AI can be used to revolutionize website development

5 mins : Oct 23, 2023

Instagram
Instagram Instagram
Youtube
Youtube Youtube
LinkedIn
LinkedIn LinkedIn
Socials

Let's Work Together

© 2025 All Rights Reserved.
Privacy policyTerms of use
DesignRush

Resources

Articles

About us

A-103, 105, Jai Estate, Mumbai. India - 421203.

Resources / Articles / About us / Services / Portfolio / Career