I have a sinple Vagrant file, which create 3 instances :
config.vm.define "node1" do |subconfig|
subconfig.vm.box = "ubuntu/trusty64"
subconfig.vm.network "private_network", ip: "192.168.33.10"
end
config.vm.define "node2" do |subconfig|
subconfig.vm.box = "ubuntu/trusty64"
subconfig.vm.network "private_network", ip: "192.168.33.11"
end
config.vm.define "master" do |subconfig|
subconfig.vm.box = "ubuntu/trusty64"
subconfig.vm.network "private_network", ip: "192.168.33.9"
subconfig.vm.provision :shell, path: "install.sh"
end
On master node, i want to generate ssh-key , then copy it to 2 other nodes. My provision shell ( install.sh ) :
apt-get install sshpass -y
ssh-keygen -t rsa -b 4096 -C "tuananh93nguyen@gmail.com" -N "" -f /home/vagrant/.ssh/id_rsa
sudo chmod -R 755 /home/vagrant/.ssh
sshpass -p vagrant ssh-copy-id -o StrictHostKeyChecking=no vagrant@192.168.33.10
sshpass -p vagrant ssh-copy-id -o StrictHostKeyChecking=no vagrant@192.168.33.11
But i got this error when running 2 last line :
> master: /usr/bin/ssh-copy-id: ERROR: No identities found
But if i ssh into master node, then run install.sh again, everything is fine . I think it may be about user permission when run on vagrant. How can i fix it ?