2010-05-15 117 views
32

我想在我的Windows XP機器上配置GIT,但SSH不斷創建並在非感性地方尋找公鑰/私鑰對,例如/.ssh/id_rsaSSH在Windows上的公鑰/私鑰對上尋找錯誤的地方

在Windows的GIT安裝中是否有配置文件,我可以將其切換到我的主目錄或其他用戶定義的位置?默認情況下,它提供了在//.ssh/id_rsa創建新的密鑰對,但是這給了我錯誤「無法創建目錄'//.ssh'。」當我能夠找到一個我可以創建它的目錄時,GIT不會在那裏看到。

+0

「無法創建目錄」錯誤可以通過以管理員身份運行'sudo'來重新啓動shell來解決。我意識到這並不能解決你的問題的根源,但認爲這是值得一提的,因爲有人會遇到這個問題可能最終在這裏 – Paul 2017-03-23 17:49:04

回答

61

想通了如何手動設置我的主目錄在Windows XP:

  1. 右鍵單擊「我的電腦」
  2. 選擇「高級」選項卡
  3. 點擊「環境變量」按鈕
  4. 在「系統變量」部分下,單擊「新建」
  5. 在「變量名稱」中輸入「home」。
  6. 在「變量值」中輸入您的配置文件的路徑。

要通過命令提示符下執行同樣的事:

setx HOME "your\path\to\home" 

(請注意後綴X - 這是用來堅持的變化)

+2

就像一個提示,我真的不記得這個選項是否可用在XP中,但至少在更新版本的Windows,您可以將其添加爲用戶變量而不是系統變量。顯然,用戶的主目錄不是一個系統範圍的東西。 – btleffler 2014-04-09 14:05:37

+0

這解決了我在Windows 10中的問題。 我正在運行Cygwin git,它並沒有拉取ssh-key。 – 2017-11-18 02:12:45

-1

在Windows 7只需將您的私有密鑰( id_rsa)C:\ Users \ .ssh FOLDER 如果.ssh文件夾不存在,只需創建它。對於Windows,cd到你的項目目錄,並做 混帳克隆SSH 下載GIT://@/.git

+2

該問題實際上與HOME沒有設置相關,因爲接受的答案指出 – kakoma 2014-10-20 16:04:58

0

我是有在Windows 7類似的問題的HOME環境變量似乎是正確設置:

$ echo $HOME 
C:\Users\craibuc 

然而,嘗試連接到測試GitHub的ssh訪問失敗:

$ ssh -Tv [email protected] 
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014 
debug1: Connecting to github.com [192.30.252.129] port 22. 
debug1: Connection established. 
Could not create directory 'C/.ssh'. 
debug1: identity file C/.ssh/id_rsa type -1 
debug1: identity file C/.ssh/id_rsa-cert type -1 
debug1: identity file C/.ssh/id_dsa type -1 
debug1: identity file C/.ssh/id_dsa-cert type -1 
debug1: identity file C/.ssh/id_ecdsa type -1 
debug1: identity file C/.ssh/id_ecdsa-cert type -1 
debug1: identity file C/.ssh/id_ed25519 type -1 
debug1: identity file C/.ssh/id_ed25519-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.6.1 
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0 
debug1: no match: libssh-0.6.0 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-ctr hmac-sha1 none 
debug1: kex: client->server aes128-ctr hmac-sha1 none 
debug1: sending SSH2_MSG_KEX_ECDH_INIT 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48 
The authenticity of host 'github.com (192.30.252.129)' can't be established. 
RSA key fingerprint is xx:xx:xx. 
Are you sure you want to continue connecting (yes/no)? yes 
Failed to add the host to the list of known hosts (C/.ssh/known_hosts). 
debug1: ssh_rsa_verify: signature correct 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: SSH2_MSG_NEWKEYS received 
debug1: Roaming not allowed by server 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey 
debug1: Next authentication method: publickey 
debug1: Trying private key: C/.ssh/id_rsa 
debug1: Trying private key: C/.ssh/id_dsa 
debug1: Trying private key: C/.ssh/id_ecdsa 
debug1: Trying private key: C/.ssh/id_ed25519 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

出於某種原因,ssh試圖訪問C/.ssh

當我設置使用setx HOME /c/users/craibuc變量並重新啓動外殼,我能夠連接:

$ ssh -T [email protected] 
Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts. 
Hi craibuc! You've successfully authenticated, but GitHub does not provide shell access. 
0

我使用機器時域策略的用戶配置文件設置爲網絡有同樣的問題驅動器(在這種情況下映射到Z:)。

當試圖從Powershell做任何事情時,我會得到這樣的消息。設置home PATH變量沒有幫助。

git clone ssh://[email protected]:1234/myproject 
Cloning into 'myproject'... 
Could not create directory '/z/.ssh'. 
The authenticity of host '[mydomain.com]:1234 ([1.1.1.1]:1234)' can't be established. 
RSA key fingerprint is 00:11:22:33:$4:55:66:77:88. 
Are you sure you want to continue connecting (yes/no)? yes 
Failed to add the host to the list of known hosts (/z/.ssh/known_hosts). 
Permission denied (publickey). 

Please make sure you have the correct access rights 
and the repository exists. 

當我從混帳bash的克隆還不錯,因爲/z/.ssh等是從外殼指向Z:\.ssh一個有效的途徑。

+0

您是否碰巧知道您爲解決問題所做的工作? – Igor 2016-12-09 10:12:48

+0

...'克隆自git bash' – nathanchere 2016-12-09 10:42:33

6

Recommended來自MSYS2的方法是將db_home的​​設置爲您的主目錄。

在正確的方向上信用於@VarunAgw對於pointing

的Git換Windows包括envdb_home,應閱讀你HOME bash的變量,但是,它是unreliable

+0

我發現一些軟件如Orcad會設置'%HOME%= C:\ Users \ [accountname] \ AppData \ Roaming \ SPB_16.6'或'C:\ SPB_data' 但由於某種原因,我不想改變它。 然後這種修改'/ etc/nsswitch.conf'的方法確實有幫助。 設置爲'/ etc/nsswitch.conf'中的以下行使ssh-keygen將默認位置設置爲'%USERPROFILE%' 'db_home:/%H' – Seagal82 2016-09-10 08:23:35

0

檢查which ssh以查看您是否正在使用/usr/bin/ssh或其他可能已經意外安裝的東西。

在我的情況下,我的SSH被替換爲巧克力安裝後rsync。運行choco uninstall rsync後,我的SSH再次運行。