Add SSH key to your host agent and verify it's present with ssh-add -L
.
If you're using a passphrase and you face issues, try adding your key with ssh-add -K {path}
, docs:
-K When adding identities, each passphrase will also be stored in
the user's keychain. When removing identities with -d, each
passphrase will be removed from it.
Configure your container like this (docker-compose.yaml)
service:
environment:
SSH_AUTH_SOCK: '/run/host-services/ssh-auth.sock'
volumes:
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
You need to ensure the container user has access to the mounted .sock
file. Change ownerhsip if you face permission denied
issues.
docker-compose run --rm --user root {service} chown {user} /run/host-services/ssh-auth.sock
Now, with this configuration, you should be able to attach to the container and run ssh-add -L
inside it to see the same key from your host.