Although most people do fine with ddev ssh
and ddev exec
, they don't actually use ssh, but are wrappers on docker exec
. In the vast majority of cases, you don't need anything like this, but if you have an application that needs to actually use the real ssh protocols to access the web container, this recipe is for you.
- Copy config.sshd.yaml and docker-compose.sshd.yaml into your project's .ddev folder. (Note that you can also incorporate the contents of config.ssshd.yaml into your config.yaml.)
- Authorize your ssh client to access the web container's ssh server by adding a
.ddev/homeadditions/.ssh/authorized_keys
, which will be copied into the ~/.ssh directory in the web container. The easiest way to do this ismkdir -p ~/.ddev/homeadditions/.ssh && cp ~/.ssh/id_rsa.pub .ddev/homeadditions/.ssh
, assuming that your public ssh key is named id_rsa.pub and is in ~/.ssh. ddev restart
- Access the web container with
ssh -p 2222 -o StrictHostKeyChecking=no localhost
(The StrictHostKeyChecking=no is required because every time you restart the container it comes up with a new "host" identity.)