Articles in this section

Unable to clone or pull updates from a remote Git repository to Plesk: Permission denied (publickey)

Plesk for Windows Plesk for Linux kb: technical ext: git

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

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:

PLESK_ERROR: 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

PLESK_ERROR: 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.

  1. Log in to Plesk GUI

  2. 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

  3. Copy the SSH public key of the Plesk subscription account:

    mceclip0.png

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.

  1. Log in to Plesk GUI

  2. Go to Domains > example.com > Git

  3. Click on the Repository Settings option:

    mceclip1.png

  4. Copy the SSH public key of the Plesk subscription account:

    mceclip2.png

 

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.

  1. Log in to GitHub

  2. In the upper-right corner of any page, click your profile photo, then click Settings:

    mceclip3.png

  3. In the user settings sidebar, click SSH and GPG keys:

    mceclip4.png

  4. Click on New SSH key:

    mceclip5.png

  5. In the Title field, add a descriptive label for the new key. For example, you might call this key: Plesk SSH key

  6. Paste the Plesk subscription SSH public key into the Key field:

    mceclip6.png

  7. Click Add SSH key:

    mceclip7.png

  8. If prompted, confirm your GitHub password:

    mceclip8.png

  9. 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:

    mceclip9.png

Bitbucket

Note: If the message Someone has already registered that SSH key will be displayed on Bitbucket, verify that the SSH public key from the Plesk subscription account is not included on other Bitbucket repositories or accounts. For more details, check Bitbucket documentation.

  1. Log in to Bitbucket

  2. In the lower-left corner, select your avatar and click on Personal settings > Click SSH keys > Click Add key

  3. Enter a Label for the new key, for example, you might call this key: Plesk SSH key

  4. Paste the Plesk domain SSH public key into the Key field and click Save

  5. 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:

    mceclip9.png

GitLab

Note: If the message Error: Key already in use will be displayed on GitLab, verify that the SSH public key from the Plesk subscription account is not included on other GitLab repositories or accounts. For more details, check GitHub documentation.

  1. Log in to GitLab

  2. In the top right corner, select your avatar and click on Preferences

  3. From the left sidebar, click on SSH Keys

  4. In the Title text box, type a descriptive name for the SSH key, for example, you might call this key: Plesk SSH key

  5. In the Key text box, paste the Plesk subscription SSH public key and click on Add key

  6. 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:

    mceclip9.png

 

Additional Information

Was this article helpful?

Comments

1 comment
Date Votes

Please sign in to leave a comment.