sshgit-bashportable-applications

Properly set SSH home in GitPortable


I would very much like to take my Git install with me wherever I go, so I have installed GitPortable via PortableApps. Unfortunately, the OpenSSH utilities available in git-bash insists on placing/searching for the .ssh folder in a nonsensical place (C/.ssh).

Now, I have seen others with the same problem, but the solution generally was to set HOME as a Windows environment variable. But this is not working for me.

From the usual Windows command prompt:

C:\Users\snb>echo %HOME%
C:\Users\snb

Showing that the environment variable is apparently set correctly. From git-bash:

snb@SNB-WORKSTATION /c/Users/snb
$ echo $HOME
C:\Users\snb

Showing that git-bash agrees. However if I test out an SSH command, OpenSSH has the completely wrong idea of where to locate the .ssh folder:

snb@SNB-WORKSTATION /c/Users/snb
$ ssh -T git@bitbucket.org
Could not create directory 'C/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)?

I'm at a loss at what to do to make OpenSSH in the GitPortable installation understand where my home directory is. Do you have any ideas other than giving in and just installing Git for Windows?

EDIT:

The OpenSSH version is:

$ ssh -V
OpenSSH_6.6.1p1, OpenSSL 1.0.1i 6 Aug 2014

The command uses the correct .ssh folder location in a Windows command prompt when using git-cmd.bat:

C:\Users\snb>ssh -T git@bitbucket.org
The authenticity of host 'bitbucket.org (131.103.20.168)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,131.103.20.168' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/snb/.ssh/id_rsa':

But I truly hate cmd.exe, I need this to work for git-bash! :)

The SSH command git-bash uses is:

$ which ssh
/bin/ssh

The /bin folder is located inside the GitPortable installation, so this would be the OpenSSH version distributed with GitPortable.

This GitPortable is based on msysgit PortableGit-1.9.5-preview20141217 github commit


Solution

  • The proper path for HOME in a bash session should be set with:

     export HOME=/c/Users/snb
    

    That would make it compatible with ssh in a unix shell.
    Using posix path seems safer considering Git is running on top of a posix run-time environment.