强制Git在目录目录中创建ssh-key

Mr *_*ker 2 git ssh

我想将项目推送到github主页.因此,我正在尝试为github创建ssh-key来管理它,但我遇到的问题是git在错误的目录中/c/Users/user82/.ssh/id_rsa)而不是在项目目录中创建了ssh-key /desktop/dogs.

我怎么能告诉Git在项目目录中创建ssh-key /desktop/dogs而不是在这个目录中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.
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 6

默认情况下,ssh键始终保存在$ HOME中(在Windows上,由git设置%USERPROFILE%,即C:\Users\<yourLogin>)

ssh将在$ HOME中查找这些键.

如果您想拥有特定于GitHub帐户的密钥,您可以:

这是$HOME/.ssh/config与:

Host github1
  HostName github.com
  User git
  IdentityFile /c/path/to/my/private/key
Run Code Online (Sandbox Code Playgroud)