I have some ssh keys I use with github. Per this page, I tested them locally:
ssh -T git@github.com
Hi doug-companyname! You've successfully authenticated, but GitHub does not provide shell access.
I'm running a docker-container and under volumes in docker-compose I have:
- ~/.ssh:/home/rstudio/.ssh
This is to give the container the same keys as local.
When I run the container if I look in ~/.ssh I do see the keys:
rstudio@9b5b5114115b:~$ ls -l ~/.ssh
total 12
-rw------- 1 1001 1001 452 Nov 7 19:35 id_ed25519
-rw-r--r-- 1 1001 1001 131 Nov 7 19:35 id_ed25519.pub
-rw-r--r-- 1 1001 1001 2212 Nov 15 16:50 known_hosts
These are indeed the same as the hosts, my local. However, when I try to do the same test I get:
rstudio@9b5b5114115b:~$ ssh -T git@github.com
bash: ssh: command not found
Why are my keys not working in my container but they work fine on local?
I suspect that your image does not have an SSH client installed by default. Add the below line in your Dockerfile.
RUN apk add --no-cache openssh-client