我想将项目推送到github主页。因此,我正在尝试为github创建ssh-key来管理它,但我遇到的问题是git在错误的目录/c/Users/user82/.ssh/id_rsa)
中而不是在项目目录/desktop/dogs
中创建了ssh-key。 / p>
如何告诉Git在项目目录/desktop/dogs
而不是在c/Users/user82
目录中创建ssh-key?
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.
答案 0 :(得分:6)
默认情况下,ssh键始终保存在$ HOME中(在Windows上,由git设置为%USERPROFILE%
,即C:\Users\<yourLogin>
)
ssh将在$ HOME中查找这些键。
如果您想拥有特定于GitHub帐户的密钥,请加:
ssh-keygen -f
更改远程URL以引用该ssh配置文件中的右侧条目。
cd / path/to/your/local/repo
git remote set-url origin github1:username/myrepo
使用$HOME/.ssh/config
:
Host github1
HostName github.com
User git
IdentityFile /c/path/to/my/private/key