skip to Main Content

I have a problem with deployer that is driving me crazy! In some of my projects I get the following error message:


[DeployerExceptionRuntimeException (128)] The command "cd /home/www/p123456/html/myproject/beta && (/usr/local/bin/git clone -b "develop" –recursive [email protected]:Starraider/myProject.git /home/www/p123456/html/myproject/beta/releases/4 2>&1)" failed.

Cloning into ‘/home/www/p123456/html/myproject/beta/releases/4’…
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.


This means that Git cannot clone the repository down to the server because it has no rights to do so. Of course the respective repository exists, but it is "private" (because it is a customer project) and therefore needs a deployment key. Of course, I had previously created a corresponding SSH key on the server with ssh-keygen -t rsa -b 4096 and entered the public key at GitHub as a deployment key. A test connection with ssh -i ~/.ssh/id_rsa -T [email protected] works fine and also "by hand" the repository can be cloned to the server without any problems.
With deployer, however, it doesn’t work, although the script doesn’t do anything different than I did by hand either!
And the crazy thing is that with the same script and the same settings etc. it works for some projects on the same server, but for some of them it doesn’t work. But then every time I log into the server with SSH and try to clone the repository "by hand" it works fine. But again with the script it still doesn’t work.

I just don’t understand how it can be that the command /usr/local/bin/git clone -b "develop" --recursive [email protected]:Starraider/myProject.git works by hand, but at the same time doesn’t work via deployment script. This is beyond my comprehension!

In the meantime, I have spent several days troubleshooting and tried countless configurations, program versions, etc., but to no success. Even the support of my provider couldn’t help me, because it would be too much work for them to rebuild the whole system with private GitHub repository and deployment script etc. to find the problem.

So my hope is that one of you might have an idea what the problem could be!!!
I would be very grateful for any tips!

I use deployer v6.8.0, git v2.36.0, PHP v7.4.30 and sourcebroker/deployer-extended-typo3 v18.1.0 to deploy TYPO3 v11 and my deploy.php looks like this:


<?php

namespace Deployer;

require_once(__DIR__ . '/vendor/sourcebroker/deployer-loader/autoload.php');
new SourceBrokerDeployerExtendedTypo3Loader();

set('repository', '[email protected]:Starraider/myProject.git');
set('web_path', 'public/');
set('shared_files', ['.env']);

set('shared_dirs', function () {
    return [
        get('web_path') . 'fileadmin',
        get('web_path') . 'uploads',
        get('web_path') . 'typo3temp/assets/_processed_',
        get('web_path') . 'typo3temp/assets/images',
        !empty(get('web_path')) ? 'var/log' : 'typo3temp/var/log',
        !empty(get('web_path')) ? 'var/transient' : 'typo3temp/var/transient',
    ];
});


host('beta')
    ->hostname('p123456.mittwaldserver.info')
    ->user('myusername')
    ->set('branch', 'develop')
    ->addSshOption('StrictHostKeyChecking', 'no')
    ->set('writable_mode', 'chmod')
    ->set('default_timeout', '600')
    ->set('keep_releases', '4')
    ->set('fetch_method', 'curl')
    ->set('public_urls', ['https://beta.myproject.de'])
    ->set('deploy_path', '/home/www/p123456/html/myproject/beta');

The ssh config file on my server looks like this:


Host github.com
        User git
        Hostname github.com
        PreferredAuthentications publickey
        IdentityFile /home/www/p123456/.ssh/id_rsa
        StrictHostKeyChecking no

CU… Sven

2

Answers


  1. I just don’t understand how it can be that the command /usr/local/bin/git clone -b "develop" --recursive [email protected]:Starraider/myProject.git works by hand, but at the same time doesn’t work via deployment script.

    The two factors which can influence the connections are:

    • the user account used by deployer: if it is not the same as the one used manually, it would not access the same $HOME/.ssh folder, with its keys and config file.
    • the passphrase associated with the private key (you can use the AddKeysToAgent yes to your .ssh/config file to make sure the key is added to the ssh-agent)
    Login or Signup to reply.
  2. I just have started using deployer, and bumped into the very same issue with a minimalistic setup.

    With some debugging, it turned out that while connecting to the server with the deployer script as remote_user went all ok, the user had access to an ssh agent different to the one when connecting manually. Hence, it had access to different ssh keys.

    That turned my attention to the forward_agent setting of deployer. Apparently, the default setting for that is set to true, which means the user has the same permissions on the server that it has on the local machine, where deployer runs.

    From the deployer docs:
    SSH agent forwarding is a specific type of local forwarding that allows you to use your local SSH keys to authenticate on remote servers. This can be useful if you want to use your local SSH keys to connect to a remote server, but don’t want to copy your keys to the remote server.

    So, in case you want to use the ssh keys set in the ssh config of the remote user, you should set forward_agent explicitly to false in the deployer script like so:

    set('forward_agent', false);
    
    // or for a specific host:
    
    host('beta')
        // …other host settings
        ->set('forward_agent', false);
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search