Score:2

Why I can not ssh to my Vagrant host? [email protected]: Permission denied (publickey)

in flag

I created 5 VMs for my project vagrant status

Current machine states:

master-1                  running (virtualbox)
master-2                  running (virtualbox)
master-3                  running (virtualbox)
node-1                    running (virtualbox)
node-2                    running (virtualbox)

I can do

vagrant ssh master-1
vagrant ssh master-2
vagrant ssh master-3

vagrant ssh-config shows

vagrant ssh-config
Host master-1
  HostName 127.0.0.1
  User vagrant
  Port 2206
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/miki/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

But

ssh [email protected]
[email protected]: Permission denied (publickey).

fails.

I checked my id_rsa.pub

ssh-rsa 
AAAAB3NzaC1yc2EAAAADAQABAAACAQCZmhxzwwJJ1z/5rgoprHc31gneGY5rzFd/giE5ehZSH75WqT1hQKQ2gZUN8A3L+04oZ9H1uOUQHJBPV5mj7+FKkE+hPuTDVSUXcbYC9DlhurbmComoMh....oIQ== jovo@jovo-IdeaPad

and I can see that all five VMs have different authorized keys

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key

What should I do to enable ssh to all five hosts from my host?

Score:0
in flag

I followed this SO post

ssh [email protected] -p 2222 -o LogLevel=FATAL -o Compression=yes -o DSAAuthentication=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /home/miki/.vagrant.d/insecure_private_key

I also found another solution by adding my id_rsa

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  config.ssh.private_key_path = ['~/.vagrant.d/insecure_private_key', '~/.ssh/id_rsa']
  config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/authorized_keys"
  (1..3).each do |i|
    config.vm.define "master-#{i}" do |master|
      master.vm.box = "ubuntu/bionic64"
    end
  end
  (1..2).each do |i|
    config.vm.define "node-#{i}" do |node|
      node.vm.box = "ubuntu/bionic64"
    end
  end

  config.vm.network "public_network", :bridge => "wlo1"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "3072"
    vb.cpus = "3"
  end
end
Score:0
us flag

You do have to copy your public key whichis being Generated or you have to generate it with the command:-

Expecting Your Hostmachine is a linux machine

->ssh-keygen -t rsa -b 4096

The above command will create a public Key in

/home/user/.ssh/id_rsa.pub

Copy that public Key and you have to paste it in the vm machine to which you want to ssh, the path where to paste it is.

->/home/user/.ssh/authorized_keys

Paste the same public key in all the vm.this will make sure your host is haveing passwordless access to all the vm machines.

In some cases there is no file called as authorized_keys in the above path you do have to create the file at that time with the permission 700.

and the very last and main thing I saw in your Config File you have changed the Port number for SSH, So your command to connect with ssh should be like,

-> ssh -p 2206 [email protected]

Some lil thing that i can do ..

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.