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?

  • How can I use `git tag --list` with information from `git log --tags`
  • `gitk` program found using the `where` command but cannot be executed?
  • How to use gitk with msys2?
  • Why do long results from Git commands kill my PowerShell prompt?
  • TortoiseGit Git Commit message from script
  • Can git retain file owner, permissions, ACLs, and file attributes on a local Windows NTFS machine?
  • Git - post-receive hook not working on remote windows server
  • Export the changed files from visual svn on current commit visual svn server on windows (powershell script)
  • 2 Solutions collect form web for “Git Command Does not Work in Windows CMD”

    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"
    

    You need to set the HOME so that the CMD will be able to find your ssh keys under the .ssh folder

    set HOME=%USERPROFILE%
    
    Git Baby is a git and github fan, let's start git clone.