5

So I have the following in my vagrant file:

config.ssh.forward_agent = true

And the following salt state:

git+ssh://git@bitbucket.org/xxx/repo.git:
  git.latest:
    - rev: rest
    - target: /home/vagrant/src

However I get a public-key error when this salt state is executed.

The annoying thing is that if I manually perform git clone git+ssh://git@bitbucket.org/xxx/repo.git from within my instance, everything works fine. Any ideas?

Michael
  • 2,258
  • 1
  • 23
  • 31
  • Can you check that the user performing the git clone is the same user that salt is using to execute the command (salt usually uses root)? – Jason Zhu Mar 12 '14 at 22:01
  • Hi Jason, you were correct with it being root however I added `- user: vagrant` to the salt state config which matches the git clone user. Unfortunately the outcome is the same... – Michael Mar 12 '14 at 22:11
  • I think it might not be using the private key file that you might key. Can you try and specify the private key to use via identity parameter. – Jason Zhu Mar 13 '14 at 01:39
  • That's actually my workaround at the moment. I have to use managed files to pull in the keys manually. However obviously that's not ideal as it requires additional setup from the developer when setting up the environment with vagrant. Agent forwarding is supposed to solve this right? – Michael Mar 13 '14 at 06:33
  • Salt might sanitize the environment variables, and ssh-agent depends on them to work. I suspect that. – Dan Garthwaite Dec 05 '14 at 02:33

2 Answers2

0

Is bitbucket.org in known_hosts file?

git+ssh://git@bitbucket.org/xxx/repo.git:
  git.latest:
    - rev: rest
    - target: /home/vagrant/src
    - require:
      - ssh_known_hosts: bitbucket.org
scthi
  • 2,205
  • 1
  • 18
  • 14
0

I had the similar requirement with capistrano. I used ssh-forwarding to checkout repo from github to the remote server. I had to add the host in ~/.ssh/config file on my machine as below.

vim ~/.ssh/config

Content

Host <some host or IP>
   ForwardAgent yes

I used * as host so that It works with any server.

bitkot
  • 4,466
  • 2
  • 28
  • 39