ssh-keygen -o
You can view the created files (one without extension and one with .pub
) under ~/.ssh/
. When creating several of them, you may want to rename them appropriately (e.g. work, pers...).
to the relevant github account: https://github.com/settings/ssh/new
The configuration file for ssh is usually not created by default so we create it:
touch ~/.ssh/config
Now paste in the config file the following:
# work account
Host work.github.com
HostName github.com
User git
IdentityFile ~/.ssh/work
# personnal account
Host pers.github.com
HostName github.com
User git
IdentityFile ~/.ssh/pers
Usually, the ssh clone url looks like this: [email protected]:<account>/<project>.git
To link the right ssh key, prepend to <account>
either pers.
or work
depending on who should be committing.
This results in the following git clone command:
git clone [email protected]:<account>/<project>.git
Now you can commit as you want and work on your cloned project with the right user.
- what is keychain parameter in config file
- why is the commit user kinda ugly looking in github when looking at the commit history?
https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/