Symptoms
Unable to add remote git repository with ssh key using the Git extension. The following error is shown in the Plesk interface:
PLESK_ERROR: Cloning Git repository example.git…
Cloning into bare repository ‘/var/www/vhosts/example.com/git/example.git’…
Server at ‘example2.com:32301’ 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_with_port_32301’.
read (example2.com): Permission denied
read (example2.com): Permission denied
read (example2.com): Permission denied
Failed to gather public SSH host key for the ‘example2.com:32301’.
Known hosts file ‘/var/www/vhosts/example.com/.ssh/git_known_hosts_with_port_32301’ doesn’t exist
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
Cause
It is a bug with ID EXTGIT-60 which is planned to be fixed in future updates of the Git extension.
Resolution
Until the bug is fixed, use the workaround:
- Connect to the server using SSH.
- Download a fix:
# wget https://plesk.zendesk.com/hc/article_attachments/360007806839/git_ssh.tar
- Backup the original file:
# mv /usr/local/psa/admin/sbin/modules/git/git_ssh{,.bak}
- Extract fix from the archieve:
# tar -xf git_ssh.tar
- Replace the original file:
# mv git_ssh /usr/local/psa/admin/sbin/modules/git/git_ssh
- Remove entries from the git_known_hosts_with_port_32301 file that correspond to the host example.com:
# ssh-keygen -f ~/.ssh/git_known_hosts_with_port_32301 -R example.com
Note: If a proxy provider, such as Cloudflare, is used, it may be required to check any restrictions of traffic.