title: Github repository returns Permission denied in cookbook
body: <p>I want to create cookbook for local develop environment with github private repository.</p>
  
  <p>However, when chef trying to clone git repo, github returns permission denied error.</p>
  
  <p>SSH forwarding is worked, and <code>SSH_AUTH_SOCK</code> env is set by cookbook 'sudo'.</p>
  
  <p>Via <code>vagrant ssh</code>, both of <code>sudo ssh -T git@github.com</code> and <code>sudo git clone git@github.com:myorg/myproject.git</code> are succeed.</p>
  
  <p>How can I fix this issue??</p>
  
  <p>This is part of my recipe</p>
  
  <pre><code>deploy_user = node["git_repository_to_deploy"]["deploy_user"]
  
  ssh_known_hosts_entry 'github.com'
  
  git "/home/#{deploy_user}/sync_folder" do
    repository 'git@github.com:myorg/myproject.git'
    reference 'master'
    action :sync
    user deploy_user
    group deploy_user
    retries 3
  end
  </code></pre>
  
  <p>and below is part of role['web'] json.</p>
  
  <pre><code>{
      "name": "web",
      "chef_type": "role",
      "json_class": "Chef::Role",
      "default_attributes": {
          "authorization": {
  
          "sudo": {
                  "include_sudoers_d": true,
                  "passwordless": true,
                  "sudoers_defaults": [
                      "env_reset",
                      "env_keep = \"COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR\"",
                      "env_keep += \"LS_COLORS MAIL PS1 PS2 QTDIR USERNAME\"",
                      "env_keep += \"LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION\"",
                      "env_keep += \"LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC\"",
                      "env_keep += \"LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \"",
                      "env_keep += \"_XKB_CHARSET XAUTHORITY SSH_AUTH_SOCK\""
                  ]
              }
          },
          "nginx": {
              "env": ["ruby"]
          },
          "ruby-env": {
              "version": "2.3.0",
              "rbenv_url":      "https://github.com/sstephenson/rbenv",
              "ruby-build_url": "https://github.com/sstephenson/ruby-build"
          }
      },
      "run_list": [
          "recipe[yum-epel]",
          "recipe[nginx]",
          "recipe[nginx-conf]",
          "recipe[nodejs]",
          "recipe[readline]",
          "recipe[ruby-env]",
          "recipe[postgresql]",
          "recipe[imagemagick]",
          "recipe[sudo]",
          "recipe[github]",
      ]
  }
  </code></pre>
  
  <p>and below is Vagrantfile.</p>
  
  <pre><code>Vagrant.configure(2) do |config|
    config.vm.box = "bento/centos-6.7"
    config.vm.network "private_network", ip: "192.168.33.10"
    config.ssh.forward_agent = true
    config.vm.synced_folder "./sync_folder", "/home/vagrant/sync_folder"
  end
  </code></pre>
  
  <p>and below is my ~/.ssh/config</p>
  
  <pre><code>Host github.com
    ForwardAgent yes
  </code></pre>
  
  <p>when I type</p>
  
  <pre><code>bundle exec knife solo bootstrap local-development
  </code></pre>
  
  <p>chef returns this error.</p>
  
  <pre><code>Recipe: github::default
    * git[/home/vagrant/sync_folder] action sync
  
      ================================================================================
      Error executing action `sync` on resource 'git[/home/vagrant/sync_folder]'
      ================================================================================
  
      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '128'
      ---- Begin output of git ls-remote "git@github.com:myorg/myproject.git" "master*" ----
      STDOUT: 
      STDERR: Permission denied (publickey).
      fatal: The remote end hung up unexpectedly
      ---- End output of git ls-remote "git@github.com:myorg/myproject.git" "master*" ----
      Ran git ls-remote "git@github.com:myorg/myproject.git" "master*" returned 128
  
  
      Running handlers:
      [2016-03-03T09:02:23+00:00] ERROR: Running exception handlers
      Running handlers complete
      [2016-03-03T09:02:23+00:00] ERROR: Exception handlers complete
      Chef Client failed. 8 resources updated in 25 seconds
      [2016-03-03T09:02:23+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
      [2016-03-03T09:02:23+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
      [2016-03-03T09:02:23+00:00] ERROR: git[/home/vagrant/sync_folder] (cloudtip::default line 10) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
      ---- Begin output of git ls-remote "git@github.com:myorg/myproject.git" "master*" ----
      STDOUT: 
      STDERR: Permission denied (publickey).
      fatal: The remote end hung up unexpectedly
      ---- End output of git ls-remote "git@github.com:myorg/myproject.git" "master*" ----
      Ran git ls-remote "git@github.com:myorg/myproject.git" "master*" returned 128
      [2016-03-03T09:02:23+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
      ERROR: RuntimeError: chef-solo failed. See output above.
  </code></pre>