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
$ ssh-keygen -t rsa -C "[email protected]" 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 [email protected] 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:
$ ls -lrt ~/.ssh/ total 28 -rw-r--r-- 1 sarangb 197121 803 Nov 27 21:10 known_hosts -rw-r--r-- 1 sarangb 197121 203 Mar 4 11:21 config -rw-r--r-- 1 sarangb 197121 1766 Mar 4 11:36 id_rsa_tempuser1 -rw-r--r-- 1 sarangb 197121 400 Mar 4 11:36 id_rsa_tempuser1.pub
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.
clip < ~\.ssh\id_rsa_tempuser1.pub
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
\.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
Note you can have multiple users to same hostname
Host github-repositories-tempuser1 HostName github.com User tempuser1 IdentityFile ~/.ssh/id_rsa_tempuser1 Host github-angeleno HostName github.com User angeleno IdentityFile ~/.ssh/id_rsa_angeleno
Once you setup
user.email to appropriate user and setup remote url properly:
git remote add origin [email protected]:tempuser1/repository1.git
you should be able to push changes as designated user.
- ubuntu OpenSSH/Keys