UtahDave / salt-vagrant-demo

Demo of Salt in Vagrant. 1 master and 2 minions
Apache License 2.0
247 stars 191 forks source link

'vagrant ssh master' requires user password #50

Closed jtlarson closed 3 years ago

jtlarson commented 4 years ago

I just installed this demo using virtualbox 6.1.2 r135662 and Vagrant 2.2.6 on Windows 10. After the install completes, I'm unable to ssh to the salt master using SSH keys--I had to enter the vagrant user password:

salt-vagrant-demo-master> vagrant ssh master
vagrant@127.0.0.1's password:
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-72-generic x86_64)Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-72-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Jan 27 17:22:06 UTC 2020

  System load:  0.08              Processes:           103
  Usage of /:   2.7% of 61.80GB   Users logged in:     0
  Memory usage: 26%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.50.10

 * Overheard at KubeCon: "microk8s.status just blew my mind".

     https://microk8s.io/docs/commands#microk8s.status

26 packages can be updated.
20 updates are security updates.

This system is built by the Bento project by Chef Software
More information can be found at https://github.com/chef/bento
Last login: Mon Jan 27 17:15:05 2020 from 10.0.2.2
vagrant@saltmaster:~$
UtahDave commented 4 years ago

Interesting. Thanks for opening this issue. I've only ever run this from an ubuntu host. I'll test on windows too.

Does vagrant on windows usually have the ability to use ssh keys to authenticate and log in to a Linux vm?

nuno-silva18 commented 4 years ago

Hello. Sorry to reopen this discussion, but I tried to replicate this issue with virtualbox 6.0.18 and Vagrant 2.2.7 on Windows 10 and was unable to do so, it did not ask me for a password when using SSH to connect to the salt-master.

@UtahDave A quick Google search didn't seem to show any specific issues relating to vagrant asking for a password on SSH and the Windows platform.

Probably an issue during installation similar to this one on StackOverflow, no? https://stackoverflow.com/questions/34598980/vagrant-ssh-promtps-for-password

UtahDave commented 4 years ago

@nuno-silva18 Thanks for your update. I appreciate you testing and reporting on your findings.

At this point, I think this was probably a bug in vagrant in a specific setup. It doesn't appear to be happening with recent versions of Vagrant and Virtualbox. I'm going to close this as having been fixed upstream.

If anyone comes across this again, please feel free to comment here and I'll reopen the issue so we can track further investigation.

Thanks everyone for your reports and your time in testing!

scaswell-bhg commented 3 years ago

I'm experiencing this exact issue. I've tried multiple clean installs with no difference. I'm running vagrant on windows with virtualbox. I'm able to use the vagrant user password to keep working; so it's not a complete blocker, but a newbie to both saltstack and vagrant is likely to give up and go home. For those who may be stuck with this try 'vagrant', without quotes, as the password.

PS salt-vagrant-demo> vagrant ssh master
vagrant@127.0.0.1's password:
vagrant@127.0.0.1's password:
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-112-generic x86_64)Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-112-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Oct  6 19:41:31 UTC 2020

  System load:  0.0               Processes:           104
  Usage of /:   3.0% of 61.80GB   Users logged in:     0
  Memory usage: 29%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.50.10

 * Kubernetes 1.19 is out! Get it in one command with:

     sudo snap install microk8s --channel=1.19 --classic

   https://microk8s.io/ has docs and details.

58 packages can be updated.
38 updates are security updates.

This system is built by the Bento project by Chef Software
More information can be found at https://github.com/chef/bento

Reproduction Steps:

  1. Sync the project via Git (or download and unzip)
  2. vagrant up
  3. vagrant ssh master
  4. prompted for password
UtahDave commented 3 years ago

Thanks for the report @scaswell-bhg .

I'm installing virtualbox and vagrant on a fresh Windows box right now so I can test again.

Can you provide the Virtualbox version and the vagrant version you're using?

scaswell-bhg commented 3 years ago
PS C:\Program Files\Oracle\VirtualBox> .\VBoxManage.exe --version
6.1.14r140239

PS C:\Program Files\Oracle\VirtualBox> vagrant version
Installed Version: 2.2.10
Latest Version: 2.2.10

You're running an up-to-date version of Vagrant!
UtahDave commented 3 years ago

Hm. This is odd. I'm using the exact same versions of Virtualbox and Vagrant as you and I'm not getting asked for the password.

I ran this on a completely fresh install of Windows.

Is there anything about your setup that you think might cause this?

scaswell-bhg commented 3 years ago

No, but that was one reason I was so surprised by this. I do have the Windows Linux Subsystem 2 installed with Ubuntu 20.04 installed, though I'm not using it for this. I've tried running via a powershell window, conEmu, and a standard cmd window with the same result. Subsequent attempts to log in also ask for a password; so it's not a first time only thing either.

Windows Specifications: Edition: Windows 10 Pro x64 Version: 2004 OS Build: 19041.508 Experience: Windows Feature Experience Pack 120.2212.31.0

UtahDave commented 3 years ago

Did you change anything in the Vagrantfile? Or try to mount any directories differently?

Like mentioned here: https://stackoverflow.com/questions/23599297/changing-vagrantfile-causes-vagrant-ssh-to-prompt-for-a-password

scaswell-bhg commented 3 years ago

No. I've made no changes to the files pulled from git. Here is what I have on disk.

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  os = "bento/ubuntu-18.04"
  net_ip = "192.168.50"

  config.vm.define :master, primary: true do |master_config|
    master_config.vm.provider "virtualbox" do |vb|
        vb.memory = "2048"
        vb.cpus = 1
        vb.name = "master"
    end

    master_config.vm.box = "#{os}"
    master_config.vm.host_name = 'saltmaster.local'
    master_config.vm.network "private_network", ip: "#{net_ip}.10"
    master_config.vm.synced_folder "saltstack/salt/", "/srv/salt"
    master_config.vm.synced_folder "saltstack/pillar/", "/srv/pillar"

    master_config.vm.provision :salt do |salt|
      salt.master_config = "saltstack/etc/master"
      salt.master_key = "saltstack/keys/master_minion.pem"
      salt.master_pub = "saltstack/keys/master_minion.pub"
      salt.minion_key = "saltstack/keys/master_minion.pem"
      salt.minion_pub = "saltstack/keys/master_minion.pub"
      salt.seed_master = {
                          "minion1" => "saltstack/keys/minion1.pub",
                          "minion2" => "saltstack/keys/minion2.pub"
                         }

      salt.install_type = "stable"
      salt.install_master = true
      salt.no_minion = true
      salt.verbose = true
      salt.colorize = true
      salt.bootstrap_options = "-P -c /tmp"
    end
  end

  [
    ["minion1",    "#{net_ip}.11",    "1024",    os ],
    ["minion2",    "#{net_ip}.12",    "1024",    os ],
  ].each do |vmname,ip,mem,os|
    config.vm.define "#{vmname}" do |minion_config|
      minion_config.vm.provider "virtualbox" do |vb|
          vb.memory = "#{mem}"
          vb.cpus = 1
          vb.name = "#{vmname}"
      end

      minion_config.vm.box = "#{os}"
      minion_config.vm.hostname = "#{vmname}"
      minion_config.vm.network "private_network", ip: "#{ip}"

      minion_config.vm.provision :salt do |salt|
        salt.minion_config = "saltstack/etc/#{vmname}"
        salt.minion_key = "saltstack/keys/#{vmname}.pem"
        salt.minion_pub = "saltstack/keys/#{vmname}.pub"
        salt.install_type = "stable"
        salt.verbose = true
        salt.colorize = true
        salt.bootstrap_options = "-P -c /tmp"
      end
    end
  end
end
UtahDave commented 3 years ago

Hm. I haven't found out a way to reproduce this issue. @scaswell-bhg Do you have another Windows machine you could try this on and see if you get the same error?

scaswell-bhg commented 3 years ago

I repeated my exact process on another windows laptop and it worked as documented. There must be a setting somewhere that's affecting this but it's beyond me to divine witch setting(s) it could be.

UtahDave commented 3 years ago

OK, thanks for trying that, @scaswell-bhg . You're right. There must be some setting. Maybe a permission somewhere that is interfering.

I'll leave this ticket open for a while. Maybe someone else will see this and know what the root cause is. But I haven't been able to track it down.

UtahDave commented 3 years ago

I appreciate you opening this ticket. I've been unable to reproduce this, unfortunately. And it looks like you only ran into this situation in one specific environment. I'm going to go ahead and close this ticket since we've been unable to make any progress into finding the root cause nor reproducing.

If anyone runs into this again, please feel free to open a new ticket and link to this one if it seems related.