Targets
A target is a named remote you sync from: a host, a user, a path and a stage. A project can have several, for example production and staging. ddev sync targets lists every target from every layer together with the file that defines it.
Your first sync creates one with ddev sync init. This page covers what init does not ask about, and where each value belongs.
Configuration layers
Section titled “Configuration layers”ddev-sync builds its configuration from several files and merges them. Later layers win:
- The profile for the project type (and, for TYPO3, the profile for the major version). It ships with ddev-sync and cannot be edited.
- Features that were detected or requested. See Syncing.
- Global:
~/.ddev/ddev-sync/config.yaml, in your home directory, shared by every project on the machine. - Project:
.ddev/ddev-sync.yaml, committed with the project. - Local:
.ddev/ddev-sync/local.yaml, this machine and this project only, git-ignored.
The global directory ~/.ddev/ddev-sync is created on the first start of a project that has the add-on. The config.yaml inside it is yours to create. The sync container mounts the directory read-only, which is what makes the file reachable from a sync and also means a sync can never write to it.
Every file you write starts with version: 1. Mappings are merged key by key, a scalar in a later layer replaces the earlier one, and lists are extended by default. ddev sync --dry-run shows which layer contributed each step, so you can see the result of a merge instead of working it out.
Profiles and features cannot define targets. Targets come only from the three files you own.
Where things belong
Section titled “Where things belong”| What | File | Why |
|---|---|---|
| Host, user, port | Global | They name your infrastructure, not the project. Every project on your machine can use them. |
| What the whole team shares: the path, the stage, the target name | Project | Committed. |
| Database passwords, S3 keys | Local | Secrets. The add-on’s .gitignore already excludes this file. |
ddev sync init never writes the global file, because the sync container mounts it read-only. It writes the target to the project file, then advises moving host and user to the global one. Do that move by hand. Because layers merge, a target can be split: the global file holds host and user, the project file holds path and stage.
Target keys
Section titled “Target keys”Every key is optional in each single layer, which is what lets you split a target across files. The resolved target must end up with a host, a path and a stage, plus, for a direct connection, a user (port defaults to 22). A target that uses ssh_alias takes both from the alias. Unknown keys are refused.
| Key | Default | Meaning |
|---|---|---|
host | Hostname or IP address. | |
user | SSH user. | |
port | 22 | SSH port. |
path | The project directory on the remote. A single trailing / is added if missing. | |
stage | required | production, staging, testing or dev. |
layout | plain | plain: code and data both under path. deployer: code in path/current/, data, environment file and uploads in path/shared/. |
provider | server | server or docker. The Docker provider is for production stacks that run in Docker. |
sync_port | Docker provider only, and required there: the port the stack publishes. | |
deployer | Read the connection from Deployer instead. See Deployer. | |
ssh_alias | A host name from ~/.ssh/config. See below. | |
jump_host, jump_host_user, jump_host_port | port 22 | A bastion to go through. See below. |
extends | The name of another target to inherit from. |
Target names must be text. YAML turns an unquoted yes, no, on, off, true, false, number or date into something else, so such a name is refused with a request to quote it.
A minimal target split over two files:
version: 1targets: production: host: web01.example user: deployversion: 1targets: production: path: /srv/app/ stage: productionA reference copy of the commented template is at .ddev/ddev-sync/ddev-sync.example.yaml, and on GitHub.
The stage
Section titled “The stage”stage is a label. The one place it appears is the warning after a run without the sanitize step: “data from production is on your machine and was not sanitized”. It does not block, enable or change anything else, so setting stage: dev on a production host does not make syncing it safer.
extends
Section titled “extends”extends lets one target inherit from another and override a few keys:
targets: staging: extends: production host: staging.example stage: stagingThe last layer to set a key wins, and an explicit value always overrides the inherited one, even when it equals the default. A chain may be at most 16 targets long, and cycles are refused.
ssh_alias
Section titled “ssh_alias”ssh_alias takes a host name from ~/.ssh/config, with user and port read from there. It is usually not what you want inside DDEV: the sync container has no ~/.ssh/config, and copying one in would not help, because its entries point at identity files and control paths that do not exist in the container. Authentication goes through DDEV’s SSH agent. Write out host, user and port instead. If both ssh_alias and host are set in one target, the alias wins.
Jump host
Section titled “Jump host”To reach the target through a bastion, set the jump host’s keys:
targets: production: host: app.internal user: deploy path: /srv/app/ stage: production jump_host: bastion.example jump_host_user: jump jump_host_port: 22The jump host is held to the same SSH rules as the target (see below): a bastion seen for the first time is trusted and remembered, and one whose key has changed is refused. It needs AllowTcpForwarding yes in its sshd_config; doctor says so when it is refused. A jump host cannot be combined with provider: docker, which has its own way of going through the Docker host.
How ddev-sync uses SSH
Section titled “How ddev-sync uses SSH”Every ssh and rsync call carries the same options:
StrictHostKeyChecking=accept-new: a host seen for the first time is trusted and remembered; a host whose key has changed is refused. Nothing is ever switched tono.BatchMode=yes: nothing is ever asked. Passwords, passphrases, two-factor prompts and host-key questions become immediate refusals. Add a key with a passphrase to the agent withddev auth sshfirst.ConnectTimeout=10.- Connection sharing: the first connection stays open for 60 seconds after its last use and the following ones reuse it, so a sync does not log in once per command. A stale connection is replaced without you noticing.
There is no agent forwarding. The sync container uses DDEV’s agent, which is why ddev-ssh-agent must not be omitted from your project.
Where known hosts are kept
Section titled “Where known hosts are kept”The remembered host keys are in .ddev/ddev-sync/home/.ssh/known_hosts. The folder survives ddev stop and is deleted by ddev add-on remove, so after a reinstall each host is accepted again on first contact. To trust a host before the first connection, add its key there yourself.
A changed host key
Section titled “A changed host key”A host seen for the first time needs nothing from you. A host that presents a different key from the one remembered is refused with ssh’s own Host key for web01.example has changed and you have requested strict checking. This is the one connection failure that needs a person, because it has two very different explanations. Either the server was rebuilt or its keys were regenerated, which is harmless, or something else is answering in its place, which is not. Find out which before you make the message go away: ask whoever runs the server, or compare the fingerprint in the full output of the failed sync with one they give you. doctor shows ssh’s words on the ssh connection row.
Once you know the new key is the right one, forget the old one and the next run remembers the new one:
ddev exec -s sync ssh-keygen -R web01.exampleUse the host that ssh’s message names. For a target with a jump_host that is the bastion’s name, not the target’s. Write it as '[web01.example]:2222' when the host does not use port 22, because ssh remembers a host on another port separately. Deleting the line from known_hosts by hand does the same.
A Docker endpoint is remembered under a name of its own, ddev-sync-endpoint-<host>-<sync_port>, and not under the address it answers on, so that two stacks published on one Docker host do not look like one host changing its key. Forget it by that name:
ddev exec -s sync ssh-keygen -R ddev-sync-endpoint-prod.example-2222The usual cause there is a redeploy that dropped the endpoint’s host-key volume, see Docker endpoint.
- Deployer: read the connection from
deploy.php. - Syncing: choose what a run does.
- Configuration: every key and its default.