I need this to simplify my drush alias configuration, so I can establish servers, jumpboxes and usernames/keys in the config file and keep everything else simpler.
1 Answers
Update: These days this operation is much easier, see https://ddev.readthedocs.io/en/latest/users/extend/in-container-configuration/
To change the /home/.ssh/config
, you just need to add a .ssh/config
file in the .ddev/homeaditions
folder and make sure to include the following lines:
UserKnownHostsFile=/home/.ssh-agent/known_hosts
StrictHostKeyChecking=no
-- The following is only valid for ddev < 1.10 --
This is the solution I've implemented:
Because I didn't want to handle multiline additions, I decided to add a config file that would be appended to the /home/.ssh/config
file.
I added a custom docker compose file in the .ddev folder: docker-compose.volumes.yml
:
version: '3.6'
services:
web:
volumes:
- "./config:/etc/custom-config"
Then created the config folder inside the .ddev folder and added a configuration file with the content I wanted: extra-config.txt
Then, simply added a post-start hook in the config.yml
file as @rfay suggested:
hooks:
post-start:
- exec: bash -c 'cat /etc/custom-config/extra-config.txt >> /home/.ssh/config'
Watch out because the commands need to be wrapped on bash -c
, otherwise it would just output stdout and not modify the file.
-
1Thanks for sharing this! It might be easier to put extra-config.txt in your project and just copy it from there, then you wouldn't need the extra docker-compose.volumes.yaml. – rfay May 08 '19 at 17:11
-
1True, but it is a project where not everybody uses ddev and each dev have their own local envs :) – pcambra May 08 '19 at 17:59