Symptoms
Unable to clone or pull updates from a remote Git repository (GitHub, Bitbucket, GitLab or others) to Plesk, one of the following errors might be displayed:
Cloning Git repository myproject.git...
Server at 'github.com' is seen for the first time.
Adding its public key to the list of known hosts in '/var/www/vhosts/example.com/.ssh/git_known_hosts'.
# github.com SSH-2.0-libssh-0.7.0
Warning: Permanently added the RSA host key for IP address '203.0.113.2' to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Public key for the server at 'github.com' is already known in '/var/www/vhosts/example.com/.ssh/git_known_hosts'. Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
Cause
The remote Git repository (GitHub, Bitbucket, GitLab or others) does not exist or the SSH public key from the Plesk subscription account is not allowed on the remote Git repository.
Resolution
Allow the connection to the remote Git repository:
1- Copy the SSH public key from the Plesk subscription account:
New remote Git repository
Note: The following steps illustrate an example with a remote GitHub account but there is no difference with other Git repository providers such as Bitbucket, Gitlab and others.
-
Go to Domains > example.com > Git > Add Repository > Select: Remote Git hosting like GitHub or BitBucket > Set the Remote Git repository. For example, GitHub:
git@github.com:jdoe/myproject.git
or BitBucket:git@bitbucket.org:jdoe/myproject.git
-
Copy the SSH public key of the Plesk subscription account:
Existing remote Git repository
Note: The following steps illustrate an example with a remote GitHub account but there is no difference with other Git repository providers such as Bitbucket, Gitlab and others.
-
Go to Domains > example.com > Git
-
Click on the Repository Settings option:
-
Copy the SSH public key of the Plesk subscription account:
2- Allow the SSH public key from the Plesk subscription account on the remote Git repository:
GitHub
Note: If the message Error: Key already in use
will be displayed on GitHub, verify that the SSH public key from the Plesk subscription account is not included on other GitHub repositories or accounts. For more details, check GitHub documentation.
-
In the upper-right corner of any page, click your profile photo, then click Settings:
-
In the user settings sidebar, click SSH and GPG keys:
-
Click on New SSH key:
-
In the Title field, add a descriptive label for the new key. For example, you might call this key:
Plesk
SSH key -
Paste the Plesk subscription SSH public key into the Key field:
-
Click Add SSH key:
-
If prompted, confirm your GitHub password:
-
If it's a new remote Git repository, go back to Plesk and continue the cloning process by clicking on OK to apply the changes…