Skip to content

Instantly share code, notes, and snippets.

@zouzias
Last active August 29, 2015 14:04
Show Gist options
  • Save zouzias/705c13f2242b79f2608e to your computer and use it in GitHub Desktop.
Save zouzias/705c13f2242b79f2608e to your computer and use it in GitHub Desktop.
Vagrant:Copy ssh private ssh key to all virtual machines
#!/bin/bash
# Iterate over all listening ssh ports of all VMs
for VM_PORT in `vagrant ssh-config | grep Port | awk '{ print $2}'`
do
echo "Copying ~/.vagrant.d/insecure_private_key to host with ssh listening on port ${VM_PORT}"
scp -i ~/.vagrant.d/insecure_private_key -P ${VM_PORT} ~/.vagrant.d/insecure_private_key vagrant@localhost:~/.ssh/id_rsa
done
# Now, each pair of vms communicates with each other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment