Git UI in PHPStorm can't connect to remote. [Windows]

Answered

For some reason Git can't connect to my remote when using the PHPStorm UI on Windows.  However from the built in terminal (and external terminals) I don't have any issue.  I'm using SSH with a "~/.ssh/config" file with no passphrase for authentication.

I've specified the proper bash.exe under the terminal settings.  
I've specified the proper Git executable under the Git settings.
Under Git settings I've used both "Native" and "Built-in" SSH mode with no luck. - https://www.jetbrains.com/help/phpstorm/using-git-integration.html#d399717e736 

I've been restarting PHPStorm after any and all configuration changes to ensure they're being used.

I've connected via SSH using the intended method outside of PHPStorm and can confirm the appropriate entry is in my "~/.ssh/known_hosts" file.  I also tried setting the file to 777 permissions to rule out the issue in this question.

I don't recall ever having this trouble before when setting up my environment, has anyone experienced similar behavior?  Is there a way to turn on additional logging which may indicate where/why it's failing?  I suspect the user the UI based Git is running as is different than the one used in the built in terminal.  Since it would have a different home directory, it wouldn't have the appropriate keys or "~/.ssh/config" file which would result in the failure, but it's just a guess.

Here is the screenshot of the particular error message:


1
7 comments

How is bash.exe related, actually? Do you try to use the git executable from WSL? It is not currently supported.

Make sure you can push/pull from the windows command prompt, and then select the Native SSH. Since you have no passphrase, it should be the best setup.

0

I use Cygwin as a bash emulator, not WSL.  I'm able to push/pull from Cygwin (I'm assuming because it picks up my "~/.ssh/config" file correctly).  Since it appears PHPStorm supports the use of "~/.ssh/config" I assumed I had to specify my bash executable with "--login -i" in order to specify what it runs the Git executable in (as well as make use of my logon scripts).  

I use the Git executable shipped with Github Desktop located at "C:\Users\<user>\AppData\Local\GitHubDesktop\app-1.0.3\resources\app\git\cmd\git.exe", not the WSL one.

I attempted to push/pull from the Windows command prompt and I cannot.  I get the following message:

ssh: Could not resolve hostname <ssh alias name>: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 

However when I attempt to ssh using the same <ssh alias name> it works.

ssh <ssh alias name>

 

I'm not familiar with WSL and would much rather use Cygwin instead.  Is there a way to instruct PHPStorm to use Cygwin over WSL for the Git UI?

0

WSL is not used, it is not supported, as I mentioned. It was only a clarification question, since you don;t use WSL, it is not related.

PHPStrom executes commands in the environment equal to the Windows command prompt. And since you cannot push from Command prompt, you cannot push from PHP storm as well.

 

The Could not resolve hostname <ssh alias name>: Name or service not known could be caused by invalid ssh connection string. Maybe the remote URL in git includes username or port that is unexpected for SSH.

 

 

0

I can push from the terminal built in to PHPStorm and from Cygwin, just not specifically the Windows command prompt (cmd.exe).  Am I mistaken for thinking the Windows command prompt does not support the "~/.ssh/config" file the way a *unix like terminal does?

I've had this working before with little trouble, but I don't recall ever setting up my Windows command prompt to use git or ssh.  Are you saying in order for PHPStorm's Git UI to work, I need to be able to use Git and SSH in my Windows command prompt specifically?

0

The command prompt is just a test because it provides the same environment that is used by the IDE to execute git commands.

Cygwin is a completely different bash and environment for git commands. IDE cannot use it for git at the moment. Terminal feature can use it, that is why git commands works form the terminal within the IDE.

So, in short yes, you need to make it work from the command prompt, then restart the IDE to load all the environment changes you did to make command prompt work, then Native SSH executable should work.

0

Great, thank you.  Installing Git Bash did the trick.  Last time I configured PHPStorm this was already installed so it seemed to just work without any additional steps.

0

Installing Git For Windows (that provides git bash as one of the features) by default configures the environment to allow using git from the command prompt. 

I believe that is what did the trick. Glad it works now,anywayy!

0

Please sign in to leave a comment.