Skip to content

Instantly share code, notes, and snippets.

@johndstein
Last active August 29, 2015 14:04
Show Gist options
  • Save johndstein/a6112d9cc1ec322004b5 to your computer and use it in GitHub Desktop.
Save johndstein/a6112d9cc1ec322004b5 to your computer and use it in GitHub Desktop.
Docker you can ssh into.
docker run -i -t ubuntu:12.04 /bin/bash
apt-get update
apt-get install -y openssh-server
mkdir /var/run/sshd
mkdir /root/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwoal3xxr7FV0n2ozHa68XWCO14Z4oWfFz6RL+uWkMwRJ5MmmEyuVaH4DVEhAy5SAxShfRrELLzQn1nvaUCv7Ta8I0qoe/1l5DTDgU25Z4AAKLzn3gLudiW1hfpU1WOEUBVoEk+UpJ4lILFlMgSB0vpGwyiAqHteMafY26JVTwWYWPTnaVFl1HBJHIOjSa0extu23w7yp80g5e7ds/yYOX8GyCCjqfUwRtMdbsL6LTPomM92k3T+EiueLUfvAleE/G2hlVPJRweyibbSlaL2teh9AWx083kUiWyUyUT4kdJ4W1THors5v1koZHdAsgtXv6LKIMxwdapT7MmSOI0dmd vagrant@vagrant-ubuntu-precise-64" > /root/.ssh/authorized_keys
!!!! IMPORTANT !!!!
in another terminal commit your docker image
docker commit CONTAINER_ID TAG
Now you can run your image
docker run -d TAG /usr/sbin/sshd -D
look up the ip address
docker inspect CONTAINER_ID
ssh into your box
ssh -i ~/.ssh/jds_insecure_id_rsa -o StrictHostKeyChecking=no [email protected]
vagrant@vagrant-ubuntu-precise-64:~$ cat ~/.ssh/jds_insecure_id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAsKGpd8ca+xVdJ9qMx2uvF1gjteGeKFnxc+kS/rlpDMESeTJp
hMrlWh+A1RIQMuUgMUoX0axCy80J9Z72lAr+02vCNKqHv9ZeQ0w4FNuWeAACi859
4C7nYltYX6VNVjhFAVaBJPlKSeJSCxZTIEgdL6RsMogKh7XjGn2NuiVU8FmFj052
lRZdRwSRyDo0mtH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pPNGNfKYSd40G
oXcw6XMGCfNAIpGrwNyIbMBAVQIsAjR4oBdRQAbDE2RIUpjWX2/BGmw/7uE0yhNi
ha2eBjlOrY4YnhyTSAhtiip4wTFgaHsoyUUbf2ip6WWnQHjlypULdnklO38zcUJO
1apR+vkCgYBAmKgNz46TJirYHNH5MOTqXfn9qfZhtZ9qplywnI6ihYBVDX3TBJc7
bpGqF9cY3sNdQVjnBKU2M1EKhZYJVj3rTwZxvL8i0MEs1L6mznrMb11cZegzaH83
LseWynPcS/Js1z5eJDyeIvTvHjZ8Adz3L0M/sxJprwDWvXJIvmKTtw==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment