{"action":"created","issue":{"url":"https://api.github.com/repos/deployphp/deployer/issues/1103","repository_url":"https://api.github.com/repos/deployphp/deployer","labels_url":"https://api.github.com/repos/deployphp/deployer/issues/1103/labels{/name}","comments_url":"https://api.github.com/repos/deployphp/deployer/issues/1103/comments","events_url":"https://api.github.com/repos/deployphp/deployer/issues/1103/events","html_url":"https://github.com/deployphp/deployer/issues/1103","id":214058611,"number":1103,"title":"Deployer stops at update_code task with permission denied (publickey) error","user":{"login":"pzaj2","id":19946083,"avatar_url":"https://avatars2.githubusercontent.com/u/19946083?v=4","gravatar_id":"","url":"https://api.github.com/users/pzaj2","html_url":"https://github.com/pzaj2","followers_url":"https://api.github.com/users/pzaj2/followers","following_url":"https://api.github.com/users/pzaj2/following{/other_user}","gists_url":"https://api.github.com/users/pzaj2/gists{/gist_id}","starred_url":"https://api.github.com/users/pzaj2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pzaj2/subscriptions","organizations_url":"https://api.github.com/users/pzaj2/orgs","repos_url":"https://api.github.com/users/pzaj2/repos","events_url":"https://api.github.com/users/pzaj2/events{/privacy}","received_events_url":"https://api.github.com/users/pzaj2/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-03-14T12:37:25Z","updated_at":"2017-07-24T13:36:19Z","closed_at":"2017-03-15T11:46:36Z","body":"| Q                 | A\r\n| ----------------- | ---\r\n| Issue Type        | Bug\r\n| Deployer Version  | 4.3.0\r\n| Local Machine OS  | Ubuntu 16.04.2 LTS\r\n| Remote Machine OS | Ubuntu 16.04.2 LTS\r\n\r\n### Description \r\nWhen running deploy from my local machine I'm receiving an error during deploy:update_code task. It's really confusing, because apparently there's an issue with SSH connection, but it would not be able to reach deploy:update_code if SSH connection didn't work (or am I missing something here?). Setting ssh_multiplexing to false does not solve the issue while setting pty(true) make it stop at \"echo $0\".\r\n\r\nJust to clarify few things (and make sure I'm doing it right). The deployer is run from local machine that uses SSH (key authentication) to remote machine. Remote machine has the ssh key for gitlab (I added it and managed to clone the repository manually from remote machine). The identityFile arguments are my local paths to SSH pub and private keys used to connect to remote machine.\r\n\r\n### Steps to reproduce\r\nrun dep deploy staging\r\n\r\n### Content of `deploy.php`\r\n```php\r\n<?php\r\nnamespace Deployer;\r\n\r\nrequire 'recipe/symfony.php';\r\n\r\n// Configuration\r\n\r\nset('ssh_type', 'native');\r\nset('ssh_multiplexing', true);\r\nset('keep_releases', 3);\r\nset('default_stage', 'staging');\r\n\r\nset('repository', '<SSH GITLAB URL>');\r\n\r\nadd('shared_files', ['app/config.parameters.yml']);\r\nadd('shared_dirs', ['app/logs', 'web/media/cache', 'web/uploads']);\r\n\r\nadd('writable_dirs', ['app/logs', 'app/cache', 'web/uploads']);\r\n\r\n// Servers\r\n\r\nserver('staging', '<SERVER URL>')\r\n    ->user('<USERNAME>')\r\n    ->identityFile('<SSH PUB>', '<SSH PRIV>')\r\n    ->stage('staging')\r\n    ->set('env', 'dev')\r\n    ->set('branch', 'develop')\r\n    ->set('clear_paths', ['web/config.php'])\r\n    ->set('deploy_path', '<DEPLOY PATH>')\r\n//    ->pty(true)\r\n;\r\n\r\n\r\n// Tasks\r\n\r\ndesc('Restart PHP-FPM service');\r\ntask('php-fpm:restart', function () {\r\n    run('sudo systemctl restart php7.0-fpm.service');\r\n});\r\n//after('deploy:symlink', 'php-fpm:restart');\r\n\r\n// [Optional] if deploy fails automatically unlock.\r\nafter('deploy:failed', 'deploy:unlock');\r\n\r\n// Migrate database before symlink new release.\r\n\r\nbefore('deploy:symlink', 'database:migrate');\r\n```\r\n\r\n### Output log\r\nExecuting task deploy:prepare\r\n[staging] > echo $0\r\n[staging] < bash\r\n[staging] > if [ ! -d [[DEPLOY PATH]] ]; then mkdir -p [[DEPLOY PATH]]; fi\r\n[staging] > if [ ! -L [[DEPLOY PATH]]/current ] && [ -d [[DEPLOY PATH]]/current ]; then echo true; fi\r\n[staging] > cd [[DEPLOY PATH]] && if [ ! -d .dep ]; then mkdir .dep; fi\r\n[staging] > cd [[DEPLOY PATH]] && if [ ! -d releases ]; then mkdir releases; fi\r\n[staging] > cd [[DEPLOY PATH]] && if [ ! -d shared ]; then mkdir shared; fi\r\n• done on [staging]\r\n✔ Ok [717ms]\r\n➤ Executing task deploy:lock\r\n[staging] > if [ -f [[DEPLOY PATH]]/.dep/deploy.lock ]; then echo 'true'; fi\r\n[staging] > touch [[DEPLOY PATH]]/.dep/deploy.lock\r\n• done on [staging]\r\n✔ Ok [226ms]\r\n➤ Executing task deploy:release\r\n[staging] > cd [[DEPLOY PATH]] && (if [ -h release ]; then echo 'true'; fi)\r\n[staging] < true\r\n[staging] > cd [[DEPLOY PATH]] && (rm -rf \"$(readlink release)\")\r\n[staging] > cd [[DEPLOY PATH]] && (rm release)\r\n[staging] > cd [[DEPLOY PATH]] && ([ -d releases ] && [ \"$(ls -A releases)\" ] && echo \"true\" || echo \"false\")\r\n[staging] < false\r\n[staging] > cd [[DEPLOY PATH]] && (if [ -d [[DEPLOY PATH]]/releases/1 ]; then echo 'true'; fi)\r\n[staging] > cd [[DEPLOY PATH]] && (date +\"%Y%m%d%H%M%S\")\r\n[staging] < 20170314130713\r\n[staging] > cd [[DEPLOY PATH]] && (echo '20170314130713,1' >> .dep/releases)\r\n[staging] > cd [[DEPLOY PATH]] && (mkdir [[DEPLOY PATH]]/releases/1)\r\n[staging] > cd [[DEPLOY PATH]] && (if [[ \"$(man ln)\" =~ \"--relative\" ]]; then echo \"true\"; fi)\r\n[staging] < true\r\n[staging] > cd [[DEPLOY PATH]] && (ln -nfs --relative [[DEPLOY PATH]]/releases/1 [[DEPLOY PATH]]/release)\r\n• done on [staging]\r\n✔ Ok [1s 174ms]\r\n➤ Executing task deploy:update_code\r\n[staging] > which git\r\n[staging] < /usr/bin/git\r\n[staging] > /usr/bin/git version\r\n[staging] < git version 2.7.4\r\n[staging] > if [ -h [[DEPLOY PATH]]/release ]; then echo 'true'; fi\r\n[staging] < true\r\n[staging] > readlink [[DEPLOY PATH]]/release\r\n[staging] < releases/1\r\n[staging] > /usr/bin/git clone -b develop  --recursive -q [[SSH GITLAB URL]] [[DEPLOY PATH]]/releases/1 2>&1\r\n➤ Executing task deploy:failed\r\n• done on [staging]\r\n✔ Ok [0ms]\r\n➤ Executing task deploy:unlock\r\n[staging] > rm -f [[DEPLOY PATH]]/.dep/deploy.lock\r\n• done on [staging]\r\n✔ Ok [113ms]\r\n\r\n                                                                                                                                                     \r\n  [RuntimeException]                                                                                                                                 \r\n  The command \"ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=5 -o ControlPath='~/.ssh/  \r\n  deployer_mux_[[USERNAME]]@[[SERVER URL]]:22' -p '22' -i '[[SSH PRIV]]' '[[SERVER URL]]' bash -s\" failed.                     \r\n  Exit Code: 128(Invalid exit argument)                                                                                                              \r\n  Working directory: /home/test                                                                                                             \r\n  Output:                                                                                                                                            \r\n  ================                                                                                                                                   \r\n  Permission denied (publickey).                                                                                                                     \r\n  fatal: Could not read from remote repository.                                                                                                      \r\n  Please make sure you have the correct access rights                                                                                                \r\n  and the repository exists.                                                                                                                         \r\n  Error Output:                                                                                                                                      \r\n  ================                                                                                                                                   \r\n                                                                                                                                                     \r\n\r\nException trace:\r\n () at phar:///usr/local/bin/dep/src/Server/Remote/NativeSsh.php:103\r\n Deployer\\Server\\Remote\\NativeSsh->run() at phar:///usr/local/bin/dep/src/functions.php:318\r\n Deployer\\run() at phar:///usr/local/bin/dep/recipe/deploy/update_code.php:59\r\n Deployer\\{closure}() at n/a:n/a\r\n call_user_func() at phar:///usr/local/bin/dep/src/Task/Task.php:85\r\n Deployer\\Task\\Task->run() at phar:///usr/local/bin/dep/src/Executor/SeriesExecutor.php:40\r\n Deployer\\Executor\\SeriesExecutor->run() at phar:///usr/local/bin/dep/src/Console/TaskCommand.php:103\r\n Deployer\\Console\\TaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Command/Command.php:262\r\n Symfony\\Component\\Console\\Command\\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:826\r\n Symfony\\Component\\Console\\Application->doRunCommand() at phar:///usr/local/bin/dep/src/Console/Application.php:123\r\n Deployer\\Console\\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:189\r\n Symfony\\Component\\Console\\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:120\r\n Symfony\\Component\\Console\\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:190\r\n Deployer\\Deployer->run() at phar:///usr/local/bin/dep/bin/dep:119\r\n require() at /usr/local/bin/dep:4\r\n\r\ndeploy [-p|--parallel] [--no-hooks]\r\n"},"comment":{"url":"https://api.github.com/repos/deployphp/deployer/issues/comments/317424442","html_url":"https://github.com/deployphp/deployer/issues/1103#issuecomment-317424442","issue_url":"https://api.github.com/repos/deployphp/deployer/issues/1103","id":317424442,"user":{"login":"pzaj2","id":19946083,"avatar_url":"https://avatars2.githubusercontent.com/u/19946083?v=4","gravatar_id":"","url":"https://api.github.com/users/pzaj2","html_url":"https://github.com/pzaj2","followers_url":"https://api.github.com/users/pzaj2/followers","following_url":"https://api.github.com/users/pzaj2/following{/other_user}","gists_url":"https://api.github.com/users/pzaj2/gists{/gist_id}","starred_url":"https://api.github.com/users/pzaj2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pzaj2/subscriptions","organizations_url":"https://api.github.com/users/pzaj2/orgs","repos_url":"https://api.github.com/users/pzaj2/repos","events_url":"https://api.github.com/users/pzaj2/events{/privacy}","received_events_url":"https://api.github.com/users/pzaj2/received_events","type":"User","site_admin":false},"created_at":"2017-07-24T13:36:19Z","updated_at":"2017-07-24T13:36:19Z","body":"@dspe You can follow this advice here: https://github.com/deployphp/deployer/issues/1103#issuecomment-286478154. It worked for me. It is a bit slower this way, but at least works fine. You can do it like this:\r\n```php\r\nset('ssh_multiplexing', false);\r\n```\r\n\r\nsomewhere in your deployment script. You probably want to place it at the top with other configuration settings."}}
{"actor":{"display_login":"pzaj2"}}