ls -al ~/.ssh
This will list out all existing public and private key pairs, if any.~/.ssh/id_rsa
is available, we can reuse it, or else we can first generate a key to the default ~/.ssh/id_rsa
by running:~/.ssh/id_rsa.pub
will be created at the default ssh location ~/.ssh/
.~/.ssh/id_rsa_work_user1.pub
pbcopy < ~/.ssh/id_rsa.
pub and then log in to your personal GitHub account:Settings
SSH and GPG keys
from the menu to the left.New SSH key
, provide a suitable title, and paste the key in the box belowAdd key
— and you’re done!For the work accounts, use the corresponding public keys (pbcopy < ~/.ssh/id_rsa_work_user1.
pub) and repeat the above steps in your GitHub work accounts.
eval '$(ssh-agent -s)'
.~/.ssh/config
file:ssh-add -l
will list all the SSH keys attached to the ssh-agent. Remove all of them and add the one key you are about to use.git config user.name
and git config user.email
. If it’s not found, update accordingly.git remote -v
git init
.git operations
should work seamlessly.ssh-keygen
command to generate SSH public and private key files. By default, these files are created in the ~/.ssh directory. You can specify a different location, and an optional password (passphrase) to access the private key file. If an SSH key pair with the same name exists in the given location, those files are overwritten.--generate-ssh-keys
option. The key files are stored in the ~/.ssh directory unless specified otherwise with the --ssh-dest-key-path
option. The --generate-ssh-keys
option will not overwrite existing key files, instead returning an error. In the following command, replace VMname and RGname with your own values:cat
command, replacing ~/.ssh/id_rsa.pub
with the path and filename of your own public key file if needed:pbcopy
. Similarly in Linux, you can pipe the public key file to programs such as xclip
.--ssh-key-values
option. In the following command, replace VMname, RGname, and keyFile with your own values:--ssh-key-values sshkey-desktop.pub sshkey-laptop.pub
.