key generation and registration
The way github identifies you is thru your ssh keys (public keys need to be registered at github & private keys live on your machine).
The way to generate keys is to find ssh-keygen
, it comes handy with git bash
$ ssh-keygen -t rsa -C "tempuser1@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/sarangb/.ssh/id_rsa): id_rsa_tempuser1
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_tempuser1.
Your public key has been saved in id_rsa_tempuser1.pub.
The key fingerprint is:
SHA256:qB2/s3LWTdGZS2yF/TqVOeh0JPAWnIpDR7ES12Si4j8 tempuser1@gmail.com
The key's randomart image is:
+---[RSA 2048]----+
| ..**+.o |
| .+.==o.o|
| ..oo..=+++|
| ...o..ooB=o|
| o.S . o+.+.|
| o o. ..+ |
| . . .E o . |
| . +.o . |
| +oo |
+----[SHA256]-----+
And now i have new keys in my ~/
directory, on windows that translate to user-home directory.
i moved the keys to ~/.ssh
directory just to be consistent:
|
|
Now to here id_rsa_tempuser1
has private key and id_rsa_tempuser1.pub
has public key portion.
Head over to github.com, in your profile settings register the public keys with appropriate caption.
|
|
The best way to do so is to use clip
command in git-bash
(note copy only public keys), this would copy it on clipboard.
setting up config files
Now that we have multiple keys generated, it is time to associate keys with accounts in config
file.
vim to \.ssh\config
or create one at location if it does not exists already and add your keys to your user.
Here i have added a temporary Host github-repositories-tempuser1
with user tempuser1
.
Note you can have multiple users to same hostname
|
|
Once you setup user.name
and user.email
to appropriate user and setup remote url properly:
git remote add origin git@github-repositories-tempuser1:tempuser1/repository1.git
you should be able to push changes as designated user.
Links (click to expand..)