-
Notifications
You must be signed in to change notification settings - Fork 12
Docker Container SSH Keys
$ mkdir ~/.ssh
Find the container id
$ docker ps
Assume it's 9109e0e544b6.
Copy the keys from the host->container:
$ docker cp ~/.ssh/id_rsa 9109e0e544b6:/root/.ssh
$ docker cp ~/.ssh/id_rsa.pub 9109e0e544b6:/root/.ssh
Now, you have to tell your ssh client to use that key with these steps:
$ eval "$(ssh-agent)"
$ ssh-add ~/.ssh/id_rsa_tleyden
Verify by finding one of the hostnames and running the following command inside your docker container:
$ cd ansible/playbooks
$ ansible ec2-54-237-94-9.compute-1.amazonaws.com -i inventory -m ping -u centos
(replacing ec2-54.. with actual hostname)
Lets say you have a key on your osx workstation called you_id_rsa_osx, and you’ve created a docker container and inside your docker container you’ve created a second key, called you_id_rsa_docker. You started the cluster on your OSX workstation, and used the you_id_rsa_osx as the key in the aws cloudformation settings.
but since you want to also be able to connect to your cluster from inside the docker container, you need to get the you_id_rsa_docker into all of the aws instances. The way you can do that is:
- Save you_id_rsa_docker somewhere on your osx workstation
- Update the
putkey.ymlfile to point to the you_id_rsa_docker file ansible-playbook -l $KEYNAME putkey.yml