7

I have these needs from time to time in the web container:

  • ssh to a server from inside the web container
  • Use git to a private repository inside the web container
  • Use rsync (like ddev drush rsync)
  • Use ddev composer with access to private repositories

So how can I get my keys into the container?

rfay
  • 9,963
  • 1
  • 47
  • 89

1 Answers1

14

DDEV supports having your ssh keys in the container without mounting them there, using an ssh-agent inside docker.

You can authenticate and add your keys via ddev auth ssh, and they will then be available from every project. This works for ssh from inside the container, private composer repositories, and drush rsync.

See https://ddev.readthedocs.io/en/stable/users/basics/cli-usage/#ssh-into-containers for docs.

rfay
  • 9,963
  • 1
  • 47
  • 89
  • 1
    Note that the `ssh-add` command is accidentally missing in ddev v1.3.0, see https://stackoverflow.com/questions/52938356/where-did-the-ssh-client-go-in-ddev-v1-3-0 for the fix. – rfay Nov 06 '18 at 22:19
  • could you please highlight the valid response more and seperate it more freom the obsolete response? Was a bit confusing at first... – mtness Feb 26 '19 at 16:36
  • 1
    Note: `ddev auth ssh` will only add keys in **OpenSSH format** – mbomb007 Mar 16 '21 at 18:35
  • 1
    Under which path can I find the keys in the web container after running `ddev auth ssh`? If I `ddev ssh` into the container and look in the `~/.ssh` directory, there is only a config file, but no key files. – Nono Mar 20 '22 at 13:21
  • The whole idea of `ddev auth ssh` is that the keys don't go into the web container. They're served by an ssh agent running in the ddev-ssh-agent container. – rfay Mar 21 '22 at 00:01
  • If you really want the ssh keys inside the container you can do it, see https://stackoverflow.com/a/61485062/215713 – rfay Mar 21 '22 at 00:26
  • The ddev link in the answer is broken . You find it at https://ddev.readthedocs.io/en/latest/users/basics/cli-usage/#ssh-into-containers – batigolix Sep 09 '22 at 09:23
  • Thanks @batigolix - I fixed the link and added a redirect in the docs. – rfay Sep 10 '22 at 13:59