david-pesticcio icon

Vagrantfile - insert user SSH key

david-pesticcio | PRO | 06/14/21 02:57:02 PM UTC | 0 ⭐ | 9877 👁️ | Never ⏰ | []
Ruby |

610 B

|

None

|

0 👍

/

0 👎

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
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎