Issue
Background:
I had a personal account that was working fine with github, then my employer gave me a new github account and so i configured my github account to use my machine generated SSH key. Now my old machine is replaced ....
How do i configure this new machine to check-in check-out code to github..
do i generate and add another key to the account? it is also asking me for email account..when i give my old([email protected]) (email added on git hub) it says:
error: invalid key: [email protected]
Directly adding it says
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'x y@DESKTOP-8ITRR8F.(no ne)')
UPDATE
windows 10 doesnot allow creating a folder .ssh in c:/users/samra/.. and when i try to generate key (thinking it may create a .ssh in the process) it says
Saving key failed: No such file or directory found
Solution
Steps to generate another ssh key:
from cmd prompt go to c:/users/xyz/mkdir .ssh
open gitbash from c:/program files/git/bin/bash.exe
type
ssh-keygen -t rsa -C "your-email-address"
Enter full path when asked for the file name (this is important)
C:/Users/xyz/.ssh/id_rsa_ge
Enter pass phrase..and your key shall be generated.
Login to your Github account "SSH and GPG keys" click New SSH Key button
Open your id_rsa_ge.pub file in a text file eg notepad and copy everything and paste into the key dialog..give any title of your choice.
In git bash Type
ssh-add ~/.ssh/id_rsa_ge
If it says "Could not open a connection to your authentication agent.", do the following commands
ssh-agent eval $(ssh-agent)
it should return a agent pid Now again repeat step 8.
Create config file in .ssh folder and type
#Default GitHub
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github-ge
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_ge
Now use git
git add .
git commit ...
git push origin master
Note: before reinstalling your OS always take a backup of keys
Answered By - Samra Answer Checked By - Willingham (WPSolving Volunteer)