Vagrant ssh using username and password

10,260

Vagrant has a few options (see full doc https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html) :

Vagrant.configure("2") do |config|
  config.ssh.username = "user"
  config.ssh.password = "password"
end

note indeed, you need to make sure those users exist on the guest os (generally most vagrant box are created with vagrant user)

To have the connection between your different VMs, you can easily do that if you assign fix IP to the VM.

Vagrant.configure("2") do |config|
  config.vm.network :private_network, ip: "192.168.45.15"
end

when you connect to your second VM, you can run ssh [email protected] and it will ssh to the first VM

Share:
10,260
abinesh s
Author by

abinesh s

Passionate to learn new things.

Updated on June 22, 2022

Comments

  • abinesh s
    abinesh s almost 2 years

    I want to connect with a vagrant machine with different user instead of Vagrant also want to use another username and password instead of using keys. Also, I want to know is it possible to use ssh vagrant vm from another vm running in same machine. If so, how to do that?