2

I want to push an project to the github homepage. Therefor, I am trying to create ssh-key for the github to manage it but I am facing problem that git creates the ssh-key in the wrong directory /c/Users/user82/.ssh/id_rsa) and not in the project directory /desktop/dogs.

How can I tell Git to create ssh-key in the project directory also /desktop/dogs and not in this directory c/Users/user82?

user82@User MINGW64 ~/desktop/dogs (master)
$ ssh-keygen -t rsa -C "example@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/user82/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/user82/.ssh/id_rsa.
Your public key has been saved in /c/Users/user82/.ssh/id_rsa.pub.
Mr Asker
  • 2,300
  • 11
  • 31
  • 56
  • 2
    ssh-keygen put the keys in the default directory which is not wrong. Git has nothing to do with this setting. Why do you want to move the keys inside the project directory? You don't need that to push the project to github. Git uses the ssh client, and the ssh client should be aware of the default location of your keys without doing anything. – rdupz May 22 '16 at 12:23
  • And, in any case, if you want the file in a different place, move it yourself? – bmargulies May 22 '16 at 12:31

1 Answers1

6

ssh keys are always saved by default in $HOME (which on Windows, is set by git to %USERPROFILE%, which is C:\Users\<yourLogin>)

ssh will look for those keys in $HOME.

If you want to have keys specific to a GitHub account, you ca:

  • generate ssh keys anywhere you want (or copy them from $HOME to anywhere you want, with any name and name.pub) with ssh-keygen -f
  • reference them in a ssh config file like this one
  • change the remote url to reference the right entry in that ssh config file.

     cd / path/to/your/local/repo
     git remote set-url origin github1:username/myrepo
    

That is with a $HOME/.ssh/config with:

Host github1
  HostName github.com
  User git
  IdentityFile /c/path/to/my/private/key
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250