I want to start a docker container that adds a ssh key at startup :
My entrypoint looks like this :
#!/bin/bash
set -e
service ssh start
su anotherUser -s /bin/bash -c "eval \"$(ssh-agent)\" && ssh-add /Keys/id_rsa"
I've seen many posts that use sudo
, but I do not have sudo
available. I've found this solution but at the startup it shows me :
[....] Starting OpenBSD Secure Shell server: sshd 7[ ok 8.
Agent pid 36
Error connecting to agent: Permission denied
But when I execute the same lines at the promp everythings is ok :
xxx# su anotherUser
anotherUser@xxx:~$ eval $(ssh-agent)
Agent pid 47
anotherUser@xxx:~$ ssh-add /keys/id_rsa
Identity added: /keys/id_rsa (yyy@yyy-HP-EliteBook-850-G4)