简体   繁体   中英

Git Command Does not Work in Windows CMD

I am trying the below command in Windows CMD for Bitnami Gitlab VM machine at Windows 10.

git clone git@192.168.1.10:user/project.git

It works in Git Bash but the same command does not work for Windows CMD.

I suspect when used in Windows CMD ssh is looking for wrong keys and the output is:

Permission denied (publickey)

The command works in Git Bash terminal but I like to use Windows CMD.

How can I fix the issue?

您需要设置HOME以便CMD能够在.ssh文件夹下找到您的ssh密钥。

set HOME=%USERPROFILE%

I suspect when used in Windows CMD ssh is looking for wrong key

You don't have to suspect. You can see it.

Check that:

  • your PATH does reference <git>/usr/bin
  • where ssh is indeed ssh.exe from <git>/usr/bin
  • HOME is set to the parent folder of your .ssh is

Then type:

ssh -Tv git@192.168.1.10

If the wrong ssh key is used, defines it in a .ssh/config file .

Host mygitserver
   Hostname 192.168.1.10
   User git
   IdentityFile "/C/path/to/my/private/key"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM