Cpanel Git™ Version Control Errors with BitBucket

C

Steps for Cloning Repo to HostGator File Manager (gotchas included!)

Coming from a graphic design background, Git has always been a bit challenging for me. I often long for a visual UI and a simple way to do the tasks without using Terminal, but in the end, I slowly work my way through step-by-step commands in Terminal.

Today, I needed to clone a static website that I added to my BitBucket repo to a shared hosting plan on HostGator. It was more challenging than I expected. If you’re running into errors, or are looking to do the same thing, I hope this write-up helps you.

1. Create SSH Keys

Although cPanel has a SSH key generator, the keys generated will not work because they have required passcodes. You are not able to Generate Key’s with the “Key Password” field blank because of form validation rules. This is gotcha number one.

Instead, you will need to generate keys manually from cPanel’s Terminal. When you generate the key manually you can leave the password blank.

Cpanel requires passcodes for SSH keys generated which won't work with BitBucket Cloning
cPanel SSH Access requires that public keys have passwords.

Will I have to use Terminal to make my HostGator SSH keys?

The answer is yes. If you are in HostGator’s cPanel, you can not use the SSH Access tool for SSH Key generation because it forces the inclusion of a password.

In cPanel terminal, which is automatically logged in for you.

Use the command:

ssh-keygen -t rsa -C YourEmailAddress

To leave a blank passphrase, click return or enter on your keyboard.

use cPanel terminal to create a key for BitBucket

2. File Manager Preparation

The next gotcha is: the folder into which you’re cloning your project must be empty. If it is not empty, you’ll get an error message such as “Error: You cannot use the “/” directory because it already contains files.”

Empty includes hidden files (files that start with a period.)

Folder must be empty to clone

3. Cpanel Git™ Version Control

What cloning address do I use from BitBucket?

I did not have success using the BitBucket clone this repo HTTPs address, even though the cPanel instructions seem to say that the clone URL could work with the HTTPS protocol. I could not get https://yourusername@bitbucket.org/yourusename/production.git to work.

Clone this repo with HTTPS
This URL provided by BitBucket for cloning via HTTPS did not work.

However, I did have success using the BitBucket clone this repo SSH address.

Clone this repo SSH
This URL provided by BitBucket for cloning via SSH did not work.

So, in cPanel’s Git Version Control field for Clone URL, I used git@bitbucket.org:yourusername/production.git successfully.

Clone URL in Git Version Control in cPanel use the git@ address
Example of where you paste your Clone URL from BitBucket

4. Paste Access Key into BitBucket

There is another possible gotcha in this step. In BitBucket you can add keys at the account level or repository level AND the same key can not be added to both. In this scenario, the key should be added to the repository.

In BitBucket, click to your repository and then branch you want to clone. Next go to Repository Settings > Security > Access Keys.

Access key - Add key in BitBucket
Access key – Add key in BitBucket

You’ll paste in your key that you generated from cPanel. You can copy the key from the SSH Access tool (even if you created the key in Terminal) or in Terminal use the command cat ~/.ssh/id_rsa.pub to reveal your code. You can then manually copy and paste it. pbcopy does not work.

copy SSH access key in cPanel

References

I hope this helped you. If you’re looking for additional resources, I found this StackOverflow post very helpful in sorting out my errors; Many of the instructions and notes included in this blog post were garnered from the StackOverflow forum post.

Happy Web Designing!

About the author

Kelly Barkhurst

Designer to Fullstack is my place to geek out and share tech solutions from my day-to-day as a graphic designer, programmer, and business owner (portfolio). I also write on Arts and Bricks, a parenting blog and decal shop that embraces my family’s love of Art and LEGO bricks!

Add comment

Recent Posts

Archives

Categories