git命令怎麼使用tortoise git已經生成的祕鑰(windows)
阿新 • • 發佈:2021-06-29
習慣了使用Tortoise git,突然想用一下git 原生命令,發現git pull執行失敗
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因是沒有配置ssh祕鑰,那可以共用tortoise git的祕鑰嗎,答案是:可以
Step1:建立資料夾 C:\Users\{yourName}\.ssh
Step2: tortoise git使用的是ppk方式生成的祕鑰,我們需要使用tortoise git下的puttygen工具轉換祕鑰
找到ppk檔案,在Conversions選單下的 Export SSH Key
儲存私鑰到.ssh目錄下檔名為id_rsa
儲存公鑰(save public key)到.ssh目錄下名為id_rsa.pub
Step3: 新建config檔案,配置你的git源資訊
# 域名地址的別名 Host xxx # 這個是真實的域名地址 Hostname [email protected] # 配置使用使用者名稱 User yourUserName # 這裡是id_rsa的目錄位置 IdentityFile ~/.ssh/id_rsa # 預設是22,如果是其他埠,一定要配置 Port 2222
以上就完成了ssh 祕鑰重用,可以使用ssh -T [email protected]命令驗證
當然你有多個git源或者已經有了id_rsa時,可以將對應的名字修改為其他名稱即可,修改包括三處:兩個檔名(公鑰和私鑰)以及config裡的IdentityFile 名稱