A
A
Alex Me2016-11-16 20:45:54
git
Alex Me, 2016-11-16 20:45:54

How to use different ssh keys in PhpStorm?

Hello!
I'm dumb, but I can't figure it out. I have a cygwin terminal on a windows machine - babun. It has ssh keys, there is also git. I have several SSH keys, it's more convenient for me - different keys for different servers.
I set up git in PhpStorm, now I want to use key authorization. In some incomprehensible way, Phpstorm itself picks up the key from the .ssh/ directory and it is the one that is stock - id_rsa, but I need to use another key to connect to gitlab - x_id_rsa is acceptable. I read it on the Internet, added a config file with the following contents to the .ssh/ directory in the baboon (I screwed up the MB in it, because I vaguely understand how it should work exactly):

host gitlab
  HostName gitlab.com
  IdentityFile ~/.ssh/x_id_rsa
  User [email protected]

But still phpstorm looks for id_rsa when I try to push to gitlab server:
1XAQiAP.png
-------------------------------
Solved the problem by reading this again manual:
https://bensch.be/phpstorm-and-git-ssh-keys
Namely these lines:
The two things you can do to fix this are:

1) copy the public and private key-pair you'd like PhpStorm to use to id_rsa.pub and id_rsa respectively

or

2) Rename the "Host" entry in ~/.ssh/config to actually match the domain in the project's .git/config file

The article cited by seriogja is also interesting - I saw resetting the cache of keys there and viewing the cached ones. In principle, I don’t need it before, I will know =)
Further, as for my problems.
1) in .ssh/config the line
Host gitlab.comshould include exactly the host to which Git connects (not just gitlab or AnyName, but gitlab.com)
2) in .ssh/config the line
IdentityFile ~/.ssh/x_id_rsa
at first everything was correct for me there - indicating relative path. Then, at random, I tried to bring it to the form /home/MyName/.ssh/x_id_rsa, which, apparently, was incorrect
3) user for gitlab should be [email protected]
No fiddling with PhpStorm settings is needed. In .git/config inside the project, everything is also OK in the stock version (out of ignorance, I added the [user] section there)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seriogja, 2016-11-17
@iamjack

Good afternoon!
Apparently, you need to repeat these steps to set up a connection using different keys to hosts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question