Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh issue on windows 7 (gitbash vs. windows cmd)

Tags:

git

windows

ssh

cmd

I am able to use ssh (i.e., for 'git' with heroku or github etc.) through GitBash, but I cannot do the same from Windows cmd prompt on the same machine. What can be the problem? If I recall correctly, it used to work from cmd prompt.

The error I'm getting is:

Permission denied (publickey). fatal: The remote end hung up unexpectedly

I got both logs: here is last four lines from cmd which are different from 'git bash':

debug1: Trying private key: /.ssh/identity
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

in case of Git bash: the respective lines are:

debug1: Trying private key: /c/Users/user1/.ssh/identity
debug1: Offering public key: /c/Users/user1/.ssh/id_rsa
debug1: Remote: Forced command: gerve user1
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.

Resolved

As hinted by @snemarch, setting following env var solved my problem:

set HOME=C:\Users\user1
like image 566
Asad Iqbal Avatar asked Dec 13 '11 22:12

Asad Iqbal


People also ask

What is the difference between Git Bash and Git CMD?

Git CMD is just like regular Windows command prompt with the git command. It lets you use all of Git features through command line. Useful if you are already familiar with Windows cmd and you only work on Windows. Git Bash emulates a bash environment on windows.

Does Git for Windows install ssh?

Yes, Git for Windows installs its own SSH client. It ships a version of OpenSSH with the package. If you're seeing /usr/bin/ssh when you run command -v ssh , then you're using the version from Git for Windows.


1 Answers

Since you are using GitHub, from cmd try

ssh -v -T [email protected]

See the keys that it is presenting. Maybe try from Git Bash also and compare the output.

This could be because %HOME% is not correctly set. Set it to the directory that contains your .ssh directory ( and hence the keys)

like image 61
manojlds Avatar answered Nov 01 '22 05:11

manojlds