{"id":15055428,"url":"https://github.com/baponkar/how-to-manage-multiple-github-or-gitlab-account","last_synced_at":"2026-02-04T18:02:25.426Z","repository":{"id":249411853,"uuid":"831415557","full_name":"baponkar/how-to-manage-multiple-github-or-gitlab-account","owner":"baponkar","description":"Manage multiple GitHub/GitLab Account by SSH","archived":false,"fork":false,"pushed_at":"2024-08-11T04:57:22.000Z","size":446,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T08:01:05.039Z","etag":null,"topics":["git","github","gitlab","ssh","ssh-key"],"latest_commit_sha":null,"homepage":"https://baponkar.github.io/how-to-manage-multiple-github-or-gitlab-account/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baponkar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-20T13:36:56.000Z","updated_at":"2024-08-11T04:57:26.000Z","dependencies_parsed_at":"2024-07-20T16:42:05.057Z","dependency_job_id":"71a34030-e1e9-449a-9396-5ee015976096","html_url":"https://github.com/baponkar/how-to-manage-multiple-github-or-gitlab-account","commit_stats":null,"previous_names":["baponkar/how-to-manage-multiple-github-or-gitlab-account"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/baponkar/how-to-manage-multiple-github-or-gitlab-account","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Fhow-to-manage-multiple-github-or-gitlab-account","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Fhow-to-manage-multiple-github-or-gitlab-account/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Fhow-to-manage-multiple-github-or-gitlab-account/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Fhow-to-manage-multiple-github-or-gitlab-account/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baponkar","download_url":"https://codeload.github.com/baponkar/how-to-manage-multiple-github-or-gitlab-account/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Fhow-to-manage-multiple-github-or-gitlab-account/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29092719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","github","gitlab","ssh","ssh-key"],"created_at":"2024-09-24T21:42:03.783Z","updated_at":"2026-02-04T18:02:25.410Z","avatar_url":"https://github.com/baponkar.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003chead\u003e\n  \u003c!-- primary meta tags--\u003e\n  \u003ctitle\u003eManage Multiple GitHub/GitLab Account\u003c/title\u003e\n  \u003cmeta name=\"title\" content=\"Manage Multiple GitHub/GitLab Account\"\u003e\n  \u003cmeta name=\"description\" content=\"In this article I have shown how to manage multiple GitHub or GitLab Account by SSH Key.\"\u003e\n\n  \u003c!--favicon--\u003e\n  \u003clink rel=\"shortcut icon\" href=\"./images/favicon.png\" type=\"image/png\"\u003e\n\u003c/head\u003e\n\n\n[![Static Badge](https://img.shields.io/badge/--maker?logo=git\u0026labelColor=white\u0026color=white)](https://git-scm.com/)\n[![Static Badge](https://img.shields.io/badge/--maker?logo=github\u0026logoColor=black\u0026labelColor=white\u0026color=white)](https://github.com)\n[![Static Badge](https://img.shields.io/badge/--maker?logo=gitlab\u0026labelColor=white\u0026color=white)](https://gitlab.com)\n\n# How to manage multiple GitHub or GitLab accounts\n#### Published on July 20, 2024\n\nWe can communicate GitHub and GitLab Repository from our local machine by HTTPS and SSH. \n Suppose you have multiple [GitHub](https://github.com) or [GitLab](https://gitlab.com) accounts and need all accounts to push and pull projects. Then it is boring to type username and password in every time. The best option is to add an SSH Key for each account then you don't need to type a username and password for every single push and pull. I am going to show the process of how to create and add an SSH key in this article.\n\n\n## GitHub \n\n* It is always good practice to see the official documentation [GitHub](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) [GitLab](https://docs.gitlab.com/ee/user/ssh.html).\n\nI am going to assume you have two user ID ```username1``` and ```username2``` which are registered with EmailID ```username1@example.com``` and ```username2@example.com``` in GitHub respectively.  \n\n## Step -1 : Creating an SSH key for ```username1```:\n\n```(bash)\n    ssh-keygen -t rsa -b 4096 -C \"username1@example.com\"\n```\n\n\u003cspan style=\"color:powderblue\"\u003e During creation of ssh key asked to location/filename and type a passphrase.Which will create two file one with filename and other with .pub extension.\n \u003c/span\u003e\n\n To see the created file in .ssh folder if you have choose to store in there  ```ls -a ~/.ssh/``` .\n\n##  Step - 2: Start the SSH and adding the generated Key:\n\n```(bash)\neval \"$(ssh-agent -s)\"\nssh-add ~/.ssh/id_rsa_username1\n```\n\n##  Step - 3: Adding SSH Key in GitHub:\n- LogIn into the GitHub Account with ```username1@example.com``` with password.\n\n- Navigate to Settings \u003e SSH Keys.\n\n\u003cimg src=\"./images/set_ssh_in_github.png\" alt=\"Add SSH in GitHub\" max-width=\"1080px\" height=\"auto\"\u003e\n\n- Ensure your key is listed. If not, paste the copied key and add it.\n\n## Step 4 : Verify the SSH Connection:\n\n```(bash)\n    ssh -T git@github.com\n```\n\nIf everything is going perfect then you will see \n\n`Hi username1! You've successfully authenticated, but GitHub does not provide shell access.`\n\n\nNow you are ready to communicate GitHub via SSH for ```usernam1``` account.\n\n* To activate SSH for  ```username2``` you need to perform all above four steps for `username2`.\n\n* Now create a config file by ```~/.ssh/config``` inside of `~/.ssh/` directory location.\n\nThe content of config file :\n```(bash)\n# GitHub Username1 Account\nHost github-username1\n    HostName github.com\n    User git\n    IdentityFile ~/.ssh/id_rsa_username1\n\n# GitHub Username2 Account\nHost github-username2\n    HostName github.com\n    User git\n    IdentityFile ~/.ssh/id_rsa_username2\n```\n\n* To clone a repository\n```(bash)\ngit clone https://github.com/username/repository.git\n```\n\n* To push from local repository to web repository\n```(bash)\necho \"# Repository Name\" \u003e\u003e README.md\ngit init\ngit add README.md\ngit commit -m \"first commit\"\ngit branch -M main\ngit remote add origin git@github.com:username/repository.git\ngit push -u origin main\n```\n\n* To check remote url for a repository\n\n```\ngit remote -v\n```\n\n* To change HTTPS remote url to SSH remote url\n```\ngit remote set-url origin git@github.com:username/repository.git\n```\n\n------------------------------------------------\n## GitLab\n\nFollow similar steps as above to set up SSH keys for GitLab accounts. The documentation for GitLab SSH keys can be found [here](https://docs.gitlab.com/ee/user/ssh.html).\n\n## Step 1: Creating an SSH key for username1\n```\nssh-keygen -t rsa -b 4096 -C \"username1@example.com\"\n```\n\n## Step 2: Start the SSH agent and add the generated key\n\n```\neval \"$(ssh-agent -s)\"\nssh-add ~/.ssh/id_rsa\n```\n\n## Step 3: Adding the SSH Key to GitLab\n\n- Log in to your GitLab account with username1@example.com and your password.\n\n- Navigate to User Settings \u003e SSH Keys.\n\n\u003cimg src=\"./images/add_ssh_in_gitlab.png\" max-width=\"1080\" height=\"auto\" alt=\"Add SSH key in GitLab\"\u003e\n- Paste the contents of your id_rsa.pub file into the \"Key\" field and save.\n\n\n## Step 4: Verify the SSH Connection \n```\nssh -T git@gitlab.com\n```\n\nIf everything is correct, you will see a message like:\n```\nWelcome to GitLab, @username1!\n```\n\n## Step 5: Configuring Multiple SSH Keys\nCreate a config file at ~/.ssh/config with the following content:\n\n```\n# GitLab Username1 Account\nHost gitlab.com\n    HostName gitlab-username1\n    User git\n    IdentityFile ~/.ssh/id_rsa_username1\n\n# GitLab Username2 Account\nHost gitlab-username2\n    HostName gitlab.com\n    User git\n    IdentityFile ~/.ssh/id_rsa_username2\n```\n\n## Step 6: Using the Configured SSH Keys\nTo clone a repository:\n\n```\ngit clone git@gitlab.com:username/repository.git\n```\n\nTo push from the local repository to the web repository:\n```\necho \"# Repository Name\" \u003e\u003e README.md\ngit init\ngit add README.md\ngit commit -m \"first commit\"\ngit branch -M main\ngit remote add origin git@gitlab.com:username/repository.git\ngit push -u origin main\n```\n\nTo check the remote URL for a repository:\n```\ngit remote -v\n```\n\nTo change the HTTPS remote URL to the SSH remote URL:\n\n```\ngit remote set-url origin git@gitlab.com:username/repository.git\n```\n\n\u003cspan style=\"color:grey; \"\u003e © 2024 baponkar  All rights reserved. \u003c/span\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaponkar%2Fhow-to-manage-multiple-github-or-gitlab-account","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaponkar%2Fhow-to-manage-multiple-github-or-gitlab-account","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaponkar%2Fhow-to-manage-multiple-github-or-gitlab-account/lists"}