ssh - Remove line in host's known_host file through Vagrant -


I have compressed a question - works only once in relation to a MySQL from SSH connections - my hosts The known_hosts file in any contradictory line of the computer.

Basically, I can not like my database GUI because the key is different for the same IP address (re-provisioning, reloading etc.).

Once I delete any offensive line, I can just get it right.

So, through the shell command of the valentine (which I provide) I host machine ~ / .ssh / known_host file?

Edit: I have found a temporary solution that includes a ~ / .ssh / config file (this includes the use of a private IP address ): ..

  Host 192.168 * * StrictHostKeyChecking A UserKnownHostsFile / dev / null   

You should let in. There is no real improvement, because this type of fix can be a matter of concern. See below for a better answer.

Sorry to remove from you what you need!

Changing HOST files from Vagrantfile:

What you really want is very simple. Vagratfile is interpreted by the warrant every time you run the trumpet command. It's a regular Ruby code, so if you want to change the HOST file, all you need to do is put the warrantyfile ruby ​​code in place of this change. Here's the example code I have put at the end of my Vagrantfile:

  requires 'tempfile' to be required 'fileutils' path = '~ / .ssh / known_hosts' temp_file = Tempfile.new ('foo') file. Open (path, 'r'). File | File.each_line do | Line | If line! ~ / REGEX_OF_LINE_YOU_WANT_TO_EXCLUDE / then temp_file.puts line end end end temp_file.rewind FileUtils.mv (temp_file.path, path) temp_file.close temp_file.unlink end ensure   

to edit notes By putting their own values ​​for the given code, REGEX_OF_LINE_YOU_WANT_TO_EXCLUDE

Hope I at least partially decide my mistake by providing answers to this question :) >

===== ========================================= ================================================== =============== For anyone in the future context (I am equally responding to To change GUEST OS files or copy files to GUEST OS:

Resolution number 1: Simple file copy You can use the fierce file provision in your Vagrantfile file after the code of VM file /home/vagrant/.ssh/known_hosts

~ / known_hosts.template >
  #products --------------------- -------------------- -------------- Vagrant.configure ('2') do the Config | # ... # is the section to add ---------------------------------- config.vm.provision : File | File | File.source = '~ / known_hosts.template' file.destination = '/home/vagrant/.ssh/known_hosts' end # ---------------------- ---------------------------------------- Finish   < / Blockquote> 

The file provisioner is written on the bad Vagrant site, and we got to thank @tmatilai which was the answer on serverfault.

Keep in mind that you should use complete path in the destination area, and this copy is being charged by the user, so the file In the desired boss will be: Group.

Resolution number 2: If you have to copy the file with the original privileges, or actually replace the file without using templates, then use well documented Consider it. In this case the copy of the file will work only if you have the file that appears inside VM (guest OS) in the file, but you have all the power of the shell.

Solution number 3: However in this case it will be redundant, you can be very powerful as a Provider Chef or Puppet Can use, and take action through one of those frameworks I do not know anything about puppetry, and can only talk about chefs. The cookbook will be very simple to create a template file (.erb) with the desired content, and then your recipe will simply place the file where necessary. Of course you will need a box with Chef package in it.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -