Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing access permissions to ~/.ssh/ folder on executing deployer/deployer package #1337

Closed
ohader opened this issue Dec 17, 2018 · 5 comments

Comments

@ohader
Copy link

ohader commented Dec 17, 2018

Describe the bug

Using Composer package deployer/deployer within DDEV docker container fails due to missing access permissions on /home/~.ssh/deployer_* (which is used as ControlPath when establishing SSH connections to remote servers).

The according error message looks like

  The command "if [ -h ~/site//release ]; then echo 'true'; fi" failed.

  Exit Code: -1 (Unknown error)

  Host Name: example-host-name.anyhost.it

  ================
  bind: Permission denied
  unix_listener: cannot bind to path: /home/.ssh/deployer_example_user@example-host-name.anyhost.it.yd0q8pFtSkojDfQY

To Reproduce

Steps to reproduce the behavior:

  1. install package using composer require --dev deployer/deployer:^6.3
  2. create file deploy.php in project root directory containing minimal scenario
<?php
namespace Deployer;
host('example-host-name.anyhost.it')
    ->user('example_user');
task('deploy', function() {
    $result = run('ls -la');
    var_dump($result);
});
  1. execute process using vendor/bin/dep deploy
  2. see the error message unix_listener: cannot bind to path: /home/.ssh/deployer_*

Expected behavior
Probably(!) the /home/.ssh directory should be writable for internal container users.

Screenshots

none

Version and configuration information

  • Host: macOS 10.14.2 (Mojave)
  • Docker: engine 18.09.0, commit 4d60db4
  • DDEV: 1.4.1
Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:43 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     false```

db drud/ddev-dbserver:v1.4.0
dba drud/phpmyadmin:v1.4.0
router drud/ddev-router:v1.4.0
commit v1.4.1
cli v1.4.1
web drud/ddev-webserver:v1.4.0
ddev-ssh-agent drud/ddev-ssh-agent:v1.4.0
domain ddev.local

@ohader ohader changed the title Missing access permissions to ~/.ssh/ folder on executing deployer/deployer package Missing access permissions to ~/.ssh/ folder on executing deployer/deployer package Dec 17, 2018
@ohader
Copy link
Author

ohader commented Dec 17, 2018

Deployer is executing remote commands like this

ssh -A \
  -o ControlMaster=auto \
  -o ControlPersist=60 \
  -o ControlPath=~/.ssh/deployer_example_user@example-host-name.anyhost.it.yd0q8pFtSkojDfQY \
  example_user@example-host-name.anyhost.it  'bash -s; printf "[exit_code:%s]" $?;'

A workaround in order to avoid using ControlPath is to disable SSH multiplexing using the following in the deploy.php file (however, disabling multiplexing might have other side effects - thus, it's really just a workaround):

host('example-host-name.anyhost.it')
    ->multiplexing(false)
    ->user('example_user');

@rfay
Copy link
Member

rfay commented Dec 17, 2018

I have to confess I've never seen usages like this, and have never heard of a client needing to write to .ssh. I'd have second thoughts about using a tool like that.

However, all you need to solve it is a post-start hook that does something like sudo chown -R $UID /root/.ssh Let us know if that fixes it.

The web container doesn't do anything with /root/.ssh except put the config there.

@ohader
Copy link
Author

ohader commented Dec 17, 2018

Thanks for your feedback, changing ownership inside the container is fine and your feedback that nothing else is using /home/.ssh is great.

SSH multiplexing is described here in more detail (Deployer just makes use of this OpenSSH feature):
https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing

This issue can be closed. Maybe it helps others facing similar scenarios.

@rfay
Copy link
Member

rfay commented Dec 17, 2018

I think it won't be too long before we'll have a properly named and permissioned user inside the web container, and then this wouldn't have been an issue. I think it's fine to leave this open and we'll sneak in at least setting permissions on /root/.ssh in the start script.

rfay added a commit to rfay/ddev that referenced this issue Jan 7, 2019
rfay added a commit to rfay/ddev that referenced this issue Jan 7, 2019
rfay added a commit to rfay/ddev that referenced this issue Jan 8, 2019
@rfay rfay closed this as completed in baa15bf Jan 9, 2019
@baschny
Copy link

baschny commented Oct 16, 2020

Thanks for your feedback, changing ownership inside the container is fine and your feedback that nothing else is using /home/.ssh is great.

SSH multiplexing is described here in more detail (Deployer just makes use of this OpenSSH feature):
https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing

This issue can be closed. Maybe it helps others facing similar scenarios.

I indeed had this problem today (unrelated to ddev, but using deployer on GitHub Actions) and your answer helped me, thanks @ohader ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants