2

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

2 Answers 2

2

Steps to generate another ssh key:

  1. from cmd prompt go to c:/users/xyz/mkdir .ssh

  2. open gitbash from c:/program files/git/bin/bash.exe

  3. type

     ssh-keygen -t rsa -C "your-email-address"
    
  4. Enter full path when asked for the file name (this is important)

     C:/Users/xyz/.ssh/id_rsa_ge
    
  5. Enter pass phrase..and your key shall be generated.

  6. Login to your Github account "SSH and GPG keys" click New SSH Key button

  7. 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.

  8. In git bash Type

     ssh-add ~/.ssh/id_rsa_ge
    
  9. 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

Sign up to request clarification or add additional context in comments.

2 Comments

But the question is to configure the machine to an existing ssh key. Hopefully, I am not wrong in understanding the question.
thanks for your response. Could you write a literal name of the config file inner .ssh folder please. And when you say inner content of the config file, "User git", Do I need only to change the work "git" with my username o the full text "User git" for my username?
1

1.) The e-mail address configuration is for your local copy, it got nothing to do with github, git needs to know your info so it can fill it in when you do a commit.

2.) the key -- of course you can generate a new key and add it to github, or you can copy the private/public keypair to your new machine, on Linux Machines you usually find it in ~/.ssh .

3.) the error you get is, because you don't have a valid key on your new machine yet. This is kind of like you try to login using a password, and instead of entering the password you just hit enter... no key, no access ;-) so you got the 2 options in 2.) to fix this.

3 Comments

So u r saying that i have to generate a new key and then add it to github..and i have no other choice..
ok how do i copy the private/public key pair to my new machine..STEPs?
Well, I usually scp it from old machine to new machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.