joplin-notes/Export-9fad9947-5bd5-4195-952b-6512c5a4beb1/Web development 83dd4e6675f04ba782a6865a434a0598/GitHub cc67e8c9e0c945a587b473d533a8d80a/Setting multiple accounts 734586287c324b9e98996805.md
2026-11-04 00:33:23 +05:30

139 lines
No EOL
4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Setting multiple accounts
Source: [https://betterprogramming.pub/how-to-use-multiple-github-accounts-with-one-computer-c9ba3f851b75](https://betterprogramming.pub/how-to-use-multiple-github-accounts-with-one-computer-c9ba3f851b75)
For windows I use
```
ssh-keygen -t rsa -C “your-email-address”
```
- **t** stands for ‘**type**’ and **rsa** is type of encryption
- **C** is for comment
3. The following will then show:
```
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/your_username/.ssh/id_rsa):
```
Copy and paste the path followed by an **identifiable name** for the file:
```
/c/Users/your_username/.ssh/id_rsa_IDENTIFIABLE_NAME_HERE
```
I named my one test for the sake of this tutorial:
```
/c/Users/your_username/.ssh/id_rsa_test
```
**Make sure you don’t override id_rsa as this is your existing key for your original account.**
It will then ask you for the following:
```
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
```
Press ‘Enter’ twice to leave it blank.
You can now type in the following command to see all the SSH keys you have on your local machine:
```
ls -al ~/.ssh
```
- **ls** lists all the files in the current directory
- **a** is for listing all files including hidden ones
- **l** is for listing in a long format
You should then get something similar to this:
```
total 46
drwxr-xr-x 1 your_username 1049089 0 Jan 26 10:40 .
drwxr-xr-x 1 your_username 1049089 0 Jan 23 12:12 ..
-rw-r--r-- 1 your_username 1049089 3326 Nov 30 11:21 id_rsa
-rw-r--r-- 1 your_username 1049089 748 Nov 30 11:21 id_rsa.pub
-rw-r--r-- 1 your_username 1049089 1675 Jan 26 10:40 id_rsa_test
-rw-r--r-- 1 your_username 1049089 399 Jan 26 10:40 id_rsa_test.pub
-rw-r--r-- 1 your_username 1049089 803 Nov 30 12:08 known_hosts
```
You should be able to see your new SSH key file. As you can see in my one I have both **id_rsa_test** and **id_rsa_test.pub**.
**id_rsa_test** is your private key stored on your machine, whilst **id_rsa_test.pub** is the public key which you will provide GitHub with.
Next you need to copy the **SSH key** which is stored in **id_rsa_test.pub** file. You can open this in text editor of your choice. I am currently using atom so I opened the file using the following command:
```
atom ~/.ssh/id_rsa_test.pub
```
You will then get something similar to this:
```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEmSbc7ms4SNIf7G0e9EqdrQRTB17VFTqRtCbQ55sSc11xZP5B07UXf9+................a955cf1GUzsNIr60E7VuVxirrr+K2WcleqifnDEg1H/VbyJtEekh4Aav9csBwemTz3test@test.com
```
The key is actually longer but I shortened it for the sake of this tutorial.
Copy this and navigate to your **GitHub account** → **Settings** → **SSH and GPG keys**
![https://miro.medium.com/max/1050/1*hGgGWVSSLZ14dfRlvHx59Q.png](https://miro.medium.com/max/1050/1*hGgGWVSSLZ14dfRlvHx59Q.png)
Click on **New SSH key**
![https://miro.medium.com/max/1050/1*Dv0QXfBnu5mcb2eKLcQxUg.png](https://miro.medium.com/max/1050/1*Dv0QXfBnu5mcb2eKLcQxUg.png)
Give your new key a title and then paste the **new generated SSH key** you copied before. ***It is a good idea to name your keys after the machine they’re from. As you can see I have three, Macbook, Windows and Cloud9 IDE***.
If you’re on a Mac you should be able to add this key on your terminal as well using the command below:
```
ssh-add ~/.ssh/id_rsa_test
```
For enabling ssh:
39
In Windows PowerShell (run as admin):
1. Check the current status of **ssh-agent**:
`Get-Service | ?{$_.Name -like '*ssh-agent*'} | select -Property Name, StartType, Status`
2. Enable the Service if it is disabled:
`Set-Service -Name ssh-agent -StartupType Manual`
3. Start the Service:
`Start-Service ssh-agent`
then
`cd ~`
4. Add your key as before:
`ssh-add <path to the key>`
Creating config file : format
```
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work
```