To configure SSH key in PhpStorm for Git integration, follow these steps:
1. Generate SSH Key:
- Open a terminal or command prompt.
- Run the command: `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"`.
- Provide a file name for the key (e.g., `id_rsa_phpfstorm`) and set a passphrase if desired.
- The SSH key pair (public and private key) will be generated.
2. Add SSH Key to SSH Agent (if applicable):
- Run the command: `eval "$(ssh-agent -s)"` to start the SSH agent.
- Add the private key to the SSH agent by running: `ssh-add ~/.ssh/id_rsa_phpfstorm` (replace with your key file path).
3. Retrieve the Public Key:
- Run the command: `cat ~/.ssh/id_rsa_phpfstorm.pub` to display the public key.
4. Configure PhpStorm:
- Open PhpStorm and go to Preferences or Settings (depending on your operating system).
- Navigate to Version Control > Git.
- In the SSH executable field, make sure the correct SSH executable is selected (e.g., "Native").
- Click on the "SSH Configurations" button.
- Click the "+" button to add a new SSH configuration.
- Set a name for the configuration (e.g., "Git SSH Key").
- In the "Private Key File" field, browse and select the private key file (e.g., `id_rsa_phpfstorm`).
- In the "Passphrase" field, enter the passphrase if you set one during key generation.
- Click OK to save the SSH configuration.
5. Configure Git to use SSH:
- Open your Git project in PhpStorm.
- Go to Preferences or Settings > Version Control > Git.
- Make sure the "SSH executable" is set to "Native".
- Under "SSH Configurations", select the SSH configuration you created earlier (e.g., "Git SSH Key").
6. Test the SSH Connection:
- Open the Terminal in PhpStorm.
- Run the command: `ssh -T git@github.com` (replace with your Git host).
- You should see a message confirming the successful connection.
Now you should be able to use Git with SSH key authentication in PhpStorm. Make sure to update the Git remote URL to use the SSH format (e.g., `git@github.com:user/repo.git`) instead of HTTPS.