SSH Key Management for WP Engine GitPush
If you use multiple SSH keys with WP Engine GitPush, or use GitPush in conjunction with WP Engine SSH Gateway, you can simplify your connection process by telling your computer in advance which SSH key is used for which service. This can be accomplished using a SSH config
file on your local machine. In this article we will explain how to configure your SSH config file for GitPush.
Create SSH Config File
- On your local machine, first navigate to your
.ssh
directory.- MacOS – Open Terminal and type:
cd ~/.ssh/
- Windows – Use Git Bash and navigate to:
/c/Users/[youruser]/.ssh/
- MacOS – Open Terminal and type:
- To create the file run:
touch config
- To edit the file run:
vi config
- Inside the file, tap
i
to insert text - Paste the following contents:
Host git.wpengine.com
User git
Hostname git.wpengine.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/wpegitkey
IdentitiesOnly yes
- To save and exit the vim editor:
esc
button then:wq
If you are using WP Engine’s SSH Gateway and GitPush, additional SSH Config contents should be added for SSH Gateway.
If you are using a different key than what is generated in our GitPush setup guide, be sure to update ~/.ssh/wpegitkey
to your own private key file path.
Add Remotes
Now that you have a config file set up for your SSH keys, you can manage your remote repositories easier. Just use your Host alias name when adding your remote repositories.
Be sure to update environmentname to the WP Engine unique name of your environment (i.e. environmentname.wpengine.com)
git remote add production [email protected]:production/environmentname.git
NEXT STEP: Learn how to add your SSH key to an environment for use with GitPush