[英]force Git to create the ssh-key in the directory directory
我想將一個項目推送到github主頁。 因此,我試圖為github創建ssh-key來對其進行管理,但是我面臨的問題是git在錯誤的目錄/c/Users/user82/.ssh/id_rsa)
而不是在項目目錄中創建了ssh-key。 /desktop/dogs
。
我如何告訴Git在項目目錄/desktop/dogs
創建ssh-key,而不在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.
ssh密鑰始終默認保存在$ HOME中(在Windows上,它由git設置為%USERPROFILE%
,即C:\\Users\\<yourLogin>
)
ssh將在$ HOME中查找那些鍵。
如果您想擁有特定於GitHub帳戶的密鑰,請執行以下操作:
ssh-keygen -f
在所需的任何位置生成ssh密鑰(或將它們從$ HOME復制到所需的任何位置,並使用任何name和name.pub)。 更改遠程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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.