Applicable to:
- Plesk
Question
Is it possible to connect to private Github repositories by using Plesk Git extension?
Answer
Yes, it is possible by establishing via SSH key generated by Plesk:
-
Go to the Github website.
-
Click the Sign in button:
-
Specify a Github username and a password in the corresponding Username or email address and Password fields:
-
Click an icon of your profile:
-
Press the Settings button:
-
Navigate to the SSH and GPG keys tab:
-
Click the New SSH key button:
-
Go to Domains > example.com > Git.
Note: change the "example.com" domain in the path above to the correct one.
and make sure that the Remote Git hosting like GitHub or BitBucket tab is selected:
-
Specify the private repository name, e.g.:
CONFIG_TEXT: git@github.com:johndoe/test.git
in the Remote Git repository field:
-
Copy the content of the SSH public key field:
back to the Github website, specify the key name in the Title field, insert the copied key from Plesk to the Key field and press the Add SSH key button:
-
Come back to Plesk and press the OK button to clone the private repository.
Comments
6 comments
Hi, the connection is successful, but the auto-deployment seems to be not working from bitbucket...
When I press the PULL UPDATES button - all OK, however, if I Commit to bitbucket, waiting few minutes and the repository is not populated automatically.
What can be the reason of this?
Hello, @Marek Kaczanowicz!
In order to automate this process, web hooks should be used, see the following page for the details:
https://docs.plesk.com/en-US/onyx/administrator-guide/website-management/git-support/using-remote-git-hosting.75848/#o76296
I am using this method mentioned here, but I am unable to connect. I always get the following error:
Public key for the server at 'github.com' is already known in '/var/www/vhosts/new.domain.com/.ssh/git_known_hosts'.
ssh: connect to host github.com port 49153: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Even if I try changing the SSH port to the default 22, I keep getting similar errors.
Any suggestions?
@Evangelos Sapountzis
The cause of this behavior is not clear, but I can see that you have resolved it by deleting id_rsa, id_rsa.pub and known_hosts file from the .ssh folder, according to https://talk.plesk.com/threads/github-integration-errors-unable-to-pull-updates-from-the-remote-repository.354967/
@... Yes, indeed. I managed to resolve it with the help of a Plesk support agent. And the solution is the one found on the link you posted.
For those who have problems to interact with their Github private repository,
here's what worked for me (Plesk Obsidian 18.x).
———
1. You don't need to create a SSH Key on Github.
Instead, you're going to create a PAT (Personal Access Token) on Github.
Make sure you copy-paste your token somewhere secure, as you won't be able to retrieve it if you lose it (you'll have to revoke it and create a new one).
Your Token is now your "password"!
————
2. Now go back to Plesk, go under your desired domain > Git,

provide your github info (https path to repo, username)
and copy your token inside the 'password' field.
———
3. If you still have trouble in Plesk: once you have your Github Token,
you'll have to SSH into your server,
with a "System User" you create in Plesk,
under your.domain > Web Hosting Access.
Give this system user '/bin/bash' access (« Access to the server over SSH: »).
Then, follow these StackOverflow instructions:
Message "Support for password authentication was removed. Please use a personal access token instead."
Of course, you'll need git installed on your server, but nowadays it usually already is.
Open a SSH session, go inside your 'httpdocs' folder.
You do not need to create a folder in 'httpdocs', git will create it named after your repo.
Once you've successfully tested 'git pull', go back to Plesk (see step 2).
Good luck!
Please sign in to leave a comment.