Skip to content

Docker Container SSH Keys

Traun Leyden edited this page Nov 10, 2015 · 5 revisions

Method 1: Copy your host ssh key into the docker container

This assumes that you have a key on your host called id_rsa which corresponds to the AWS key you used to kick off the cluster.

In the docker container:

$ mkdir ~/.ssh

From the host:

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

NOTE: if you are using a different keyname than id_rsa/ida_rsa.pub, you will need to tell your ssh client to use that key with these steps:

$ eval "$(ssh-agent)"
$ ssh-add ~/.ssh/id_rsa_tleyden

Verify SSH key

From the container

Find one of the hostnames from the AWS console and then ssh into it with the centos user:

(replacing ec2-54.. with actual hostname)