SSH connecting to a local server... default user directory ignored

I am trying to configure SSH on a windows server and I'm attempting to connect to it with SourceTree.

The server is Windows 2008 R2, with Bitvise SSH installed, configured and running as expected. (I can SSH in via putty... everything is working as expected)

In both Bitvise and git, I have configured the default / starting directories to be D:\ (the data drive, large enough to hold all of our repositories)

When I'm on the server, running a shell window (sh.exe --login -i) opens the the D drive as I would expect... as does an SSH connection via putty... but when I attempt to connect to the server using SourceTree... I am told that the folder I'm browsing to "doesn't appear to be a git repository"

This obviously suggests a pathing problem, and with further log diving... I have confirmed this to be the case.

My Actual structure:

D:\repo\project.git

SourceTree is attampting to find my project at:

C:\Program Files(x86)\Git\repo\project.git

Here is the connection URL I am using:

ssh://USER@IP.ADDRESS.HERE/repo/project.git

Checking my server SSH logs... I can see that the following command is running when SourceTree connects:

sh.exe --login -i -c "git-upload-pack '/repo/project.git'"

And I recieve the following error message:

fatal: protocol error: bad line length character: Welc
fatal: 'C:\Program Files (x86)\Git\repo\project.git' does not appear to be a git repository

This is, of course, true... there is no repo at that location... but if I execute "sh.exe --login -i" on the run dialog on the server... the path is correctly opened to the D drive.

I'm sure that I'm just missing something simple here...

What do I need to do to force the starting directory to be D:\ rather than C:\...\Git when SourceTree connects to a local server?

Please note that I can successfully clone this repo if I use the file protocol (the D drive on this server is a network share)... but this is far too slow for production use.

Thank you for your help!

James Carpenter

3 answers

1 accepted

Accepted Answer
0 votes

So for anyone finding this question... here are the steps to fix the problem I was having.

  • on the server, I had to edit the /etc/profile file and add the following line

HOME="/d"
just above the following:
# normalize HOME to unix path
HOME="$(cd "$HOME" ; pwd)"

This hard coded the home directory in git to the D drive for all users (which is where our repos are located).

After making this fix... it uncovered another problem that was causing SourceTreet to die.

The Message of the Day /etc/motd had some default text in it... which was printing out each time a user connected over ssh... and SourceTree was choking on it. Removing the text from this file fixed the final error we were running into.

Any ideas?

I have tried everything I can think of but everything is resulting in the same error.

A little diheartend by the total lack of support here... does noone have any experience to even provide a suggestion?

Here is a screenshot of a PuTTY connection...

  1. upon connecting to the server over SSH, I am correctly set to the D drive
  2. upon running sh.exe doing nothign but running a PWD command... I am also presented with the correct directory

regardless of what I do, I am presented with the following dialog in SourceTree:

Anyone have ANY ideas? This looks to be a git setup issue... but I can't figure out what to do differently...

I have been reading through mountains of documentation without any success.

The basic question is:

How go I make git start all my users off in the D:\ directory rather than the C:\Program Files(x86)\Git directory?

Thank you for your help

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

203 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you