How to Configure cPanel Git™ Version Control with SSH Key Authentication
This guide provides a step by step explanation for creating and managing Git™ repositories in cPanel with GitHub.com.
This guide can be used to:
- Generate SSH Keys for Private and Public Key Pairs.
- Preconfigure SSH Access to launch projects from a repository on GitHub.com to cPanel by using the SSH deploy key.
- Create new repositories or clone existing remote repositories into your cPanel account.
Step 1: Log in to your cPanel server and use the Terminal feature under the Advanced tab, or access your cPanel server via SSH.
Step 2: Run the following command to generate the private and public SSH keys which will be used to preconfigure SSH Access to a remote Git repository.
CAUTION: When this command prompts you to enter a passphrase, press enter to skip adding a passphrase. cPanel Git™ Version Control is not compatible with keys that use a passphrase.
ssh-keygen -t ed25519 -C "INSERT COMMENT OR LABEL" -f ~/.ssh/cpanel_key
-C flag specifies a comment to add to your public key. This can be helpful for you to identify which public keys you have authorized in a remote repository. You may put any arbitrary string as the comment, or even omit it entirely.
-f flag determines what name will be used for your private and public keys. If you omit the -f flag entirely, your keys will be created at
~/.ssh/id_ed25519.pub. When specifying the
-f flag, there is no need to specify the public key name as it will always be the same name as the private key, but with
.pub appended to the end.
Step 3: Create the SSH Configuration file:
Step 4: Open
~/.ssh/config with the text editor of your choice, enter the following configuration and save the file.
NOTE: The asterisk character represents the domain name of the host.
Be sure to also use the path to your private key that you generated in step 2 for the ‘IdentityFile’.
Step 5: Return to the Terminal in your cPanel or preferred SSH client and configure the Public key to authorize access. Simply enter the following command to cat the contents of the public key. Ensure you maintain the path to the public key that was generated in step 2.
Proceed to paste the output from the command above into the section for Deploy keys in your GitHub repository and save.
Step 6: Set the permission for
~/.ssh/config from “664” to “644”.
back to the cPanel Terminal or SSH clients, and perform a test clone of the repository to see if authentication works effectively. Use the SSH repository URL that you obtained from your Git provider from step 7 above.
Step 7: If authentication was successful, you may proceed to create new repositories or clone existing remote repositories within the cPanel Git™ Version Control icon.