Vagrant.configure("2") do |config| config.vm.provision "shell" do |s| ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip s.inline = <<-SHELL echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys echo #{ssh_pub_key} >> /root/.ssh/authorized_keys SHELL end config.vm.define "node2" do |node2| node2.vm.box = "generic/ubuntu2010" node2.vm.network "forwarded_port", guest: 8080, host: 8880 end config.vm.define "node1" do |node1| node1.vm.box = "generic/ubuntu2010" node1.vm.network "forwarded_port", guest: 8080, host: 8080 end end