PHPStorm, Github, Bitbucket SSH key integration

Answered

I'm struggling with getting this setup.  I want to use Github for public repositories and BitBucket for private repositories.  I've created the SSH key pairs and registered with both: id_rsa and id_rsa_bb.  These exist in ~/.ssh/  i have a config file for gh and bb with the right information in.  From terminal I can interact as I would expect.

PHPStorm is set up to use Git.  The path to git executable is set and tested.  I have set up user id and password for Github and tested (but I don't really want to use this, I want to use SSH keys.)  SSH is using built-in.  BitBucket plugin is downloaded and installed from that chaps fork, not from Atlassian (sorry, I forget his name.)  Login and password is set in preferences for the plugin and tested.

So, switching to PHPStorm, these are my scenarios I'm trying to test:

  1. No Github repository, create PHPStorm project.  Add file. Commit to Git. Push to Master: create remote repository and push file.
  2. Github repository, clone PHPStorm project from that.  Add file.  Commit to Git.  Push to Master - file added to remote repository
  3. No BitBucket repository, create PHPStorm project.  Add file. Commit to Git. Push to Master: create remote private repository and push file.
  4. BitBucket private repository, clone PHPStorm project from that.  Add file.  Commit to Git.  Push to Master - file added to remote repository


What I don't know of course is what is/isn't possible with PHPStorm so that doesn't help.  I don't find the inbuilt help that helpful in this case although it does mention having to have SSH keypairs in ~/.ssh with the default name and a config file if using different keys.

Can anyone help me work out what I need to do in PHPStorm in each of these scenarios?

Thanks,

Andrew

0
5 comments
Avatar
Permanently deleted user

Scenario 1 I think I have almost working so that may do for me.  Create a git repository remotely, no files.  In PHPStorm, create a project, add a file, add to git local, commit.   I have the github preference set to github.com with my userid and an invalid password (if I test, it won't work.)   So, in PHPStorm, Push... this brings up a dialog which requires me to Define Remote.  I do this with a URL git@github.com:username/reponame.git.  That seems to work and I'm assuming is using SSH key because the github config in preferences has the wrong password.

If that is the case, then I think I'm good to go.  Not quite my scenario 1 but close enough frankly.  

Interestingly, I could start with no remote repository and "Share project on Github" and that works BUT I have to enter user id and password.  Not what I want.

I thought I had Bitbucket working as well using the same overall approach. When defining remote I entered git@bitbucket.org:username/reponame.git but it errored with using the SSH key id_rsa.  So somewhere it isn't picking up the config I've set in ~/.ssh.  Any ideas?


Regards

Andrew

0
Avatar
Permanently deleted user

Sorry if I'm answering my own questions!  I tried for ages to get this going (and I'm pretty new to this stuff) but it all seems to have clicked now.

For BitBucket, I had the ~/.ssh/config defined incorrectly.  I used bitbucket.org for HostName not Host; changing Host to bitbucket.org and then defining remote using the url git@bitbucket.org:user/reponame.git picked up the correct SSH key to use.

I guess to recap for others:

  1. Create the repository remotely in github or bitbucket
  2. Ensure your ~/.ssh/config is set up correctly with the right Host values (github.com or bitbucket.org) as appropriate.
  3. Ensure your keys are correctly entered in ~/.ssh/config against IdentifyFile (e.g. id_rsa and id_rsa_bb)
  4. That's it from what I can tell.  I don't think it even matters if you have github preferences or the bitbucket plugin configured with the right user name and password.  


I suppose the thing to remember is that "Define Remote" has to be done for every new project at the first push and that the remote repository (master) has to exist.  I daresay there's something I've missed to make it easier but it would be good if this could all be done within PHPStorm preferences.

Regards

Andrew

0
Avatar
Permanently deleted user

Hi

I know, that this post is very old, but probably I found a solution.

You have to set different ssh client to use by IntelliJ, WebStorm etc.

Go to:

File -> Settings -> Version COntrol -> Git -> SSH executable: Native

 

Then settings from terminal ssh will by applied.

2
Avatar
Permanently deleted user

This is not applicable anymore, since this option has been removed, but the problem still persists with PhpStorm 2019.1

0

Eugen, please clarify what VCS service you're using, and what does the IDE log have in it when you are trying to push/pull to this service.

0

Please sign in to leave a comment.