docker-archive / for-azure

27 stars 18 forks source link

Adding SSH key to authorized_keys #37

Open davidwneary opened 7 years ago

davidwneary commented 7 years ago

Hi,

I want to add another ssh key to the authorized keys of each of the nodes in my swarm so a colleague can also ssh into the swarm - is there a way to do this without logging into each node in turn?

I thought something like this might do the trick:

swarm-exec docker run -v /home/docker/.ssh:/docker-ssh bash bash -c  "echo \"<PUBLIC SSH KEY>\" >> /docker-ssh/authorized_keys"

but the file remained unchanged. I tested this on my local machine and it had the correct effect but not on the swarm

Sorry if this isn't the correct place to ask this, let me know if I should ask elsewhere.

Cheers Dave

davidwneary commented 7 years ago

I just came across this image that does the same thing I was trying to do but, again, has no effect at all despite a successful message 'New key added to authorized_keys'

ddebroy commented 7 years ago

@davidwneary you need to insert the key in the /home/docker/.ssh/authorized_keys file inside the docker4x/agent-azure container. So you need something along the lines of: swarm-exec docker exec agent /bin/bash -c "cmd"