Shell firewall and emergency do not work with bitpack

I cannot force the provision of vagabonds to clone private git repositories from a bitbucket. I have a tramp 1.6.3.

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" config.ssh.forward_agent = true config.vm.define "abox" do |abox| abox.vm.box = "ubuntu/trusty32" abox.vm.hostname = "abox" abox.ssh.forward_agent = true abox.vm.network "private_network", ip: "192.168.50.4" abox.vm.network "forwarded_port", guest: 22, host: 2233 abox.vm.network "forwarded_port", guest: 6340, host: 6340 abox.vm.network "forwarded_port", guest: 8080, host: 6388 abox.vm.provision :shell, :path => "provisioning/ssh_keys.sh", :privileged => false abox.vm.provision :shell, :path => "provisioning/setup_project.sh" end end 

Where in ssh_keys I have:

 function create_key() { ssh-add -L >> ~/.ssh/authorized_keys ssh-keyscan -t rsa 127.0.0.1 > ~/.ssh/known_hosts } create_key 

Then in setup_project I call:

 su - vagrant -c "ssh-keyscan bitbucket.org >> /home/vagrant/.ssh/known_hosts && \ ssh-keyscan github.com >> /home/vagrant/.ssh/known_hosts" echo 'Clone bitbucket repo' su - vagrant -c "cd /vagrant && git clone git@bitbucket.org :someuser/some-project-that-i-have-access-to.git" 

Output:

 Permission denied (publickey). ==> abox: fatal: Could not read from remote repository. ==> abox: ==> abox: Please make sure you have the correct access rights ==> abox: and the repository exists. Error: Error while executing git clone -q git@bitbucket.org :someuser/some-project-that-i-have-access-to.git localclone 

However, when I vagrant ssh in the field and then calls the same git clone command - everything works. I also tested the available configuration, but the problem was exactly the same.

What is wrong here?

+2
source share
1 answer

Shell provisioning will be performed in the context of the guest machine (see docs ).

So you just need to change setup_project (you can also delete the key using ssh-keygen before cloning, so you don't get duplicate entries in ~/.ssh/known_hosts ):

 ssh-keygen -R bitbucket.org ssh-keyscan bitbucket.org >> /home/vagrant/.ssh/known_hosts ssh-keygen -R github.com ssh-keyscan github.com >> /home/vagrant/.ssh/known_hosts echo 'Clone bitbucket repo' cd /vagrant git clone git@bitbucket.org :someuser/some-project-that-i-have-access-to.git 
+4
source

Source: https://habr.com/ru/post/989955/


All Articles