Skip to content

Instantly share code, notes, and snippets.

@ingydotnet
Created March 8, 2012 19:38
Show Gist options
  • Save ingydotnet/2002897 to your computer and use it in GitHub Desktop.
Save ingydotnet/2002897 to your computer and use it in GitHub Desktop.
# Setup keys for ssh'ing into the LXC containers
su stackato -c "ssh-keygen -t rsa -N '' -f /home/stackato/.ssh/id_rsa > /dev/null"
ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa > /dev/null
cat /home/stackato/.ssh/id_rsa.pub | tee --append /home/stackato/.ssh/authorized_keys > /dev/null
cat /root/.ssh/id_rsa.pub | tee --append /home/stackato/.ssh/authorized_keys > /dev/null
chown stackato:stackato /home/stackato/.ssh/authorized_keys
chmod 600 /home/stackato/.ssh/authorized_keys
# Create the special key pair to be used by users for
# `stackato ssh`
su - stackato -c "ssh-keygen -t rsa -N '' -f ~/.ssh/stackato_ssh"
# This key-pair is restricted to run the stackato-ssh script
echo -n 'command="/home/stackato/bin/stackato-ssh" ' > /tmp/k
cat ${STACKATO_HOME}/.ssh/stackato_ssh.pub >> /tmp/k
su - stackato -c "cat /tmp/k >> ~/.ssh/authorized_keys"
rm -f /tmp/k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment