6

Is there a command that I can use to get Vagrant to regenerate a new key for ssh login via vagrant ssh or do I need to manually generate a new key and insert it into the right place in the .vagrant folder?

2 Answers 2

1

I did the following, and it worked for me.

Inventory File

#application servers
[app]
192.168.60.4 app1
192.168.60.5 app2

# Database server
[db]
192.168.60.6 db

# Group 'multi' with all servers
[multi:children]
app
db

# Variables that will be applied to all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key

My Vagrant file looks like the following:

VAGRANTFILE_API_VERSION="2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # General Vagrant VM coniguration
  config.vm.box="geerlingguy/centos7"
  config.ssh.insert_key = false
  config.vm.synced_folder ".", "/vagrant",disabled: true
  config.vm.provider :virtualbox do |v|
    v.memory = 256
    v.linked_clone = true
  end

  #Application server 1.
  config.vm.define "app1" do |app|
    app.vm.hostname = "orc-app1-test"
    app.vm.network :private_network, ip: "192.168.60.4"
  end

  #Application server 2.
  config.vm.define "app2" do |app|
    app.vm.hostname = "orc-app2-test"
    app.vm.network :private_network, ip: "192.168.60.5"
  end

  #Database server 1.
  config.vm.define "db" do |app|
    app.vm.hostname = "orc-db-test"
    app.vm.network :private_network, ip: "192.168.60.6"
  end
  #ansible playbook provisioner
#   config.vm.provision"ansible"do|ansible|
#   ansible.playbook = "playbook.yml"
#  end
end

Also, make sure your KnownHost file is clean.

vi /Users/JohnDoe/.ssh/known_hosts

Basically that's how I'm using my Vagrant with SSH/Ansible

-1

If you type vagrant ssh-config it'll show you the location of the vagrant's ssh key. Now, when you remove the key, Vagrant will automatically generate a new one when you run vagrant up

2
  • 1
    That doesn't work. Login still fails after regenerating the key.
    – DaSch
    Commented Oct 26, 2016 at 11:57
  • @DaSch Have you figured out how to fix that in yr case? Which error do u have? Commented Dec 20, 2016 at 12:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .