Search code examples
ruby-on-railsubuntuamazon-web-serviceschef-infrachef-recipe

avoid RSA key fingerprint while running bundle update


I am using Opscode chef, for my infrastructure management and code deployment. But I am facing a issue, whenever I run bundle install from recipe it asks for RSA key fingerprint and expects input. But the recipe fails to continue further. Some how I need to remove this RSA fingerprint during bundle install or bundle update. How do I remove it using recipe/cookbook to deploy ruby on rails application.


Solution

  • Create these files (where <bundle_user> is the user that will run the bundle commands or the attribute that references it):

    ### recipes/ssh_config.rb
    directory "#{<bundle_user>}/.ssh" do
      mode 00755
      owner <bundle_user>
    end
    
    cookbook_file "#{bundle_user}/.ssh/config" do
      source "ssh_config"
      owner <bundle_user>
      mode 00644
    end
    
    
    ### files/default/ssh_config
    Host github.com
      StrictHostKeyChecking no
    

    Then, before the deploy resource runs, include_recipe "your_cookbook::ssh_config". This will disable the SSH fingerprint verification for github.com.

    Note that this has security implications (notably, it makes it easier to suffer a MITM attack).