<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sufyan Liaquat</title>
    <description>The latest articles on DEV Community by Sufyan Liaquat (@sufyan_liaquat_01).</description>
    <link>https://dev.to/sufyan_liaquat_01</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3716316%2Fbea870a9-8ee9-48ff-a96c-80505d6edc04.jpg</url>
      <title>DEV Community: Sufyan Liaquat</title>
      <link>https://dev.to/sufyan_liaquat_01</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sufyan_liaquat_01"/>
    <language>en</language>
    <item>
      <title>How to use 2 githubs in 1 pc using ssh (Windows &amp; linux)</title>
      <dc:creator>Sufyan Liaquat</dc:creator>
      <pubDate>Sun, 25 Jan 2026 18:42:38 +0000</pubDate>
      <link>https://dev.to/sufyan_liaquat_01/how-to-use-2-githubs-in-1-pc-using-ssh-windows-linux-kg6</link>
      <guid>https://dev.to/sufyan_liaquat_01/how-to-use-2-githubs-in-1-pc-using-ssh-windows-linux-kg6</guid>
      <description>&lt;p&gt;Hey people, so recently when I joined a new company, I faced a new problem regarding version control. I have been using my personal github from beginning, but there I had to use company's github to collaborate on the project and push new changes. But it was only for 1 project and I was working on 2 projects at the same time. For the other project I had to use my own github.&lt;/p&gt;

&lt;p&gt;So, for the first few days I was juggling between 2 different accounts. I used to first login into company's account, work on the project, push new changes and then remove its credentials from Manage Github credentials and login my personal account again and then work on another project. So, as you can tell this was so &lt;strong&gt;overwhelming&lt;/strong&gt; switching accounts again and again. So, I reasearched online and got the whole solution. I will provide the commands here for both linux and windows. &lt;br&gt;
so follow these steps 1 by 1 &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create ssh keys
&lt;/h2&gt;

&lt;p&gt;first create ssh keys for both accounts using their emails. &lt;/p&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Personal&lt;/strong&gt;&lt;br&gt;
  &lt;em&gt;ssh-keygen -t rsa -b 4096 -C "&lt;a href="mailto:your_email@example.com"&gt;your_email@example.com&lt;/a&gt;" -f ~/.ssh/id_rsa_personal&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;work&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;ssh-keygen -t rsa -b 4096 -C "&lt;a href="mailto:work@example.com"&gt;work@example.com&lt;/a&gt;" -f ~/.ssh/id_rsa_work&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;ssh-keygen -t rsa -b 4096 -C "&lt;a href="mailto:personalmail@gmail.com"&gt;personalmail@gmail.com&lt;/a&gt;" -f %USERPROFILE%.ssh\id_rsa_personal&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;work&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;ssh-keygen -t rsa -b 4096 -C "&lt;a href="mailto:workmail@gmail.com"&gt;workmail@gmail.com&lt;/a&gt;" -f %USERPROFILE%.ssh\id_rsa_work&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;if it says  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Saving key "~/.ssh/id_rsa_personal" failed: No such file or directory&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;then create directory first &lt;br&gt;
&lt;em&gt;mkdir %USERPROFILE%.ssh&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When prompted for passphrase, you can press Enter twice to leave it empty&lt;/p&gt;

&lt;p&gt;Once done, your key pair will be created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Public key: C:\Users\PC-Name.ssh\id_rsa_personal.pub&lt;/li&gt;
&lt;li&gt;Public key: C:\Users\PC-Name.ssh\id_rsa_work.pub&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Stast SSH agent and add these keys
&lt;/h2&gt;

&lt;p&gt;After creating those above keys, you have to add those in ssh agent first so that it can recognize them later. &lt;/p&gt;

&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;eval "$(ssh-agent -s)"&lt;/em&gt;&lt;br&gt;
&lt;em&gt;ssh-add ~/.ssh/id_rsa_personal&lt;/em&gt;&lt;br&gt;
&lt;em&gt;ssh-add ~/.ssh/id_rsa_manager&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For Powershell&lt;/strong&gt; &lt;br&gt;
&lt;em&gt;Start-Service ssh-agent&lt;br&gt;
Get-Service ssh-agent&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;for CMD&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;net start ssh-agent&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If it says "The requested service has already been started", that’s okay, it means it’s running.&lt;/p&gt;

&lt;p&gt;Now run &lt;br&gt;
&lt;em&gt;ssh-add $env:USERPROFILE.ssh\id_rsa_personal&lt;/em&gt;&lt;br&gt;
&lt;em&gt;ssh-add $env:USERPROFILE.ssh\id_rsa_work&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You should see:&lt;br&gt;
&lt;em&gt;Identity added: C:\Users\PC-Name.ssh\id_rsa_personal&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Create or edit the SSH config file
&lt;/h2&gt;

&lt;p&gt;You will either have to create config file for ssh if it doesn't exist or you can edit one if its already there. That configuration will be used for pushing or pulling data later. &lt;/p&gt;

&lt;h3&gt;
  
  
  Linux:
&lt;/h3&gt;

&lt;p&gt;first run&lt;br&gt;
&lt;em&gt;notepad ~/.ssh/config&lt;/em&gt;&lt;br&gt;
then copy paste this below&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Host github.com-personal&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;HostName github.com&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;User git&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;IdentityFile ~/.ssh/id_rsa_personal&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Host github.com-work&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;HostName github.com&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;User git&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;IdentityFile ~/.ssh/id_rsa_work&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows:
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;notepad $env:USERPROFILE.ssh\config&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;then copy paste this below &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Host github.com-personal&lt;br&gt;
  *HostName github.com&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;User git&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;IdentityFile C:\Users\PC-Name.ssh\id_rsa_personal&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Host github.com-work&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;HostName github.com&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;User git&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;IdentityFile C:\Users\PC-Name.ssh\id_rsa_work&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Save and close.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Add SSH keys to both GitHub accounts
&lt;/h2&gt;

&lt;p&gt;Now we have to add those ssh keys we created earlier to both of our accounts respectively so that our config we created in above step can authenticate and work properly &lt;/p&gt;

&lt;h3&gt;
  
  
  Linux:
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;cat ~/.ssh/id_rsa_personal.pub&lt;/em&gt;&lt;br&gt;
&lt;em&gt;cat ~/.ssh/id_rsa_work.pub&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows:
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;cat $env:USERPROFILE.ssh\id_rsa_personal.pub&lt;/em&gt;&lt;br&gt;
&lt;em&gt;cat $env:USERPROFILE.ssh\id_rsa_work.pub&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Go to GitHub → Settings → SSH and GPG keys → New SSH key, and add the right one to each account.&lt;/p&gt;

&lt;h2&gt;
  
  
  5: Update the repo to use the work account’s key
&lt;/h2&gt;

&lt;p&gt;Inside the work’s repo folder, set the remote to use the work account’s host:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cd path/to/work-project&lt;br&gt;
git remote set-url origin &lt;a href="mailto:git@github.com-work"&gt;git@github.com-work&lt;/a&gt;:WorkUsername/repo-name.git&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Notice how we used:&lt;br&gt;
&lt;em&gt;github.com-work&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This matches the Host name you defined earlier in your SSH config:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Host github.com-work&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;HostName github.com&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;User git&lt;/em&gt;&lt;br&gt;
  &lt;em&gt;IdentityFile ~/.ssh/id_rsa_work&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For personal projects use &lt;/p&gt;

&lt;p&gt;&lt;em&gt;git remote set-url origin &lt;a href="mailto:git@github.com-personal"&gt;git@github.com-personal&lt;/a&gt;:YourUsername/repo-name.git&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6: Use work’s name and email in that project
&lt;/h2&gt;

&lt;p&gt;In the work’s project folder, set work's credentials locally (not global):&lt;/p&gt;

&lt;p&gt;cd path/to/work-project&lt;br&gt;
&lt;em&gt;git config user.name "Work Account Name"&lt;/em&gt;&lt;br&gt;
&lt;em&gt;git config user.email "&lt;a href="mailto:work-email@example.com"&gt;work-email@example.com&lt;/a&gt;"&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7: Verify setup
&lt;/h2&gt;

&lt;p&gt;verify all the settings and configuration we did above &lt;/p&gt;

&lt;p&gt;&lt;em&gt;git config user.name&lt;/em&gt;&lt;br&gt;
&lt;em&gt;git config user.email&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Test the remote host:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ssh -T &lt;a href="mailto:git@github.com-manager"&gt;git@github.com-manager&lt;/a&gt;&lt;/em&gt;&lt;br&gt;
&lt;em&gt;ssh -T &lt;a href="mailto:git@github.com-personal"&gt;git@github.com-personal&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your personal repos use → &lt;a href="mailto:git@github.com-personal"&gt;git@github.com-personal&lt;/a&gt;:...&lt;/li&gt;
&lt;li&gt;Your work repo uses → &lt;a href="mailto:git@github.com-work"&gt;git@github.com-work&lt;/a&gt;:...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you still have any questions, you can reach out to me on my email as &lt;em&gt;&lt;a href="mailto:sufyanliaquat58@gmail.com"&gt;sufyanliaquat58@gmail.com&lt;/a&gt;&lt;/em&gt;. &lt;br&gt;
Thank you.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>github</category>
      <category>linux</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
