How to enable password ssh authentication for Vagrant VM?

I'd like to enable password ssh authentication (and keep key-based authentication enabled) for may Vagrant VM. How to set that?


Vagrant.configure("2") do |config| = "fedora/26-cloud-base"
  config.vm.box_version = "20170705"

  config.ssh.username = 'vagrant'
  config.ssh.password = 'a'
  config.ssh.keys_only = false
$ sudo vagrant ssh-config 
Host default
  User vagrant
  Port 22
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/jakub/src/kubernetes-vms/kubernetes/.vagrant/machines/default/libvirt/private_key
  LogLevel FATAL

Password a is not accepted with this settings.

I guess the might be PasswordAuthentication no in output of vagrant ssh-config. How can that option be switched on?

For me the following works. You need to ssh to the vm as usual and then edit /etc/ssh/sshd_config. There you need to set PasswordAuthentication to yes instead of no. This will allow password authentication.

config.ssh - Vagrantfile, we will change the ssh server configuration of our vagrant machine such that it will accept Duration: 13:19 Posted: May 18, 2018 In this video we will learn how to ssh to vagrant machine using username and password. we will change the ssh server configuration of our vagrant machine such that it will accept password based

If you want to force password authentication for the VM, you would need to set the following from your Vagrantfile

  config.ssh.username = 'vagrant'
  config.ssh.password = 'vagrant'
  config.ssh.insert_key = false

You need to make sure the vagrant user in the VM has the corresponding password. I am not sure for the box you use so you'll need to verify yourself. It works for following box: ubuntu/trusty64

SSH to Vagrant machine using username and password, vagrant up Bringing machine 'default' up with 'virtualbox' provider. vagrant ssh-​config Host default HostName User ubuntu Port It shows that the password authentication is disabled, but seems like it did not  Vagrant Instance already added to VirtualBox, VMware or any other provider you use. SSH service on Vagrant instance set to start on boot up; Step 1: Generate SSH Keys. Generate ssh private and public keys using the ssh-keygen command. My vagrant appliance working directory is ~/vagrant/centos-asterisk-server. This is where SSH keys will reside.


Vagrant.configure("2") do |config| = "fedora/26-cloud-base"
  config.vm.box_version = "20170705"

  config.vm.provision 'shell', inline: 'echo "vagrant:a" | chpasswd'

Line config.vm.provision 'shell', inline: 'echo "vagrant:a" | chpasswd' invokes shell provisioning that changes password of vagrant user (provided the box comes with predefined user called vagrant).

Then one can connect not only by vagrant ssh but also

ssh vagrant@<vm-ip>

How to change the ssh auth method from password to private key , When connecting with phpseclib\Net\SFTP->login('user','password') to an in /​etc/ssh/sshd_config # To disable tunneled clear text passwords, I used Vagrant to create a VM with an altered /etc/ssh/sshd_config so that my  If you were using Vagrant on your local computer, you would go to Vagrants website and download a .box file. Or, you would use packer to create a new box file. You then reference that box file when you are provisoining machines, and Vagant builds a machine from that box file based on your specifications.

To ssh with password, this will automatically update the sshd config on debian/stretch64:

config.vm.provision "shell", inline: <<-SHELL
  sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config    
  service ssh restart

"PasswordAuthentication yes" required for user/pass login to , Allow vagrant ssh to login with different usernames #1295 config.ssh.password - This sets a password that Vagrant will use to = "hashicorp/​precise32" config.ssh.username = "produser"  When accessing certain admin-level pages (adjusting your user profile, for example), you may notice that you're prompted for your password, even though you're already logged in. This is by design, and aims to help guard protect you if your screen is unlocked and unattended.

centos 7, only using below is not enough. by this way , I guess that it just make su vagrant become by password. I cannot find anything why below does not work in the official site.

Vagrant.configure("2") do |config| = "centos/7"

  config.ssh.username = 'vagrant'
  config.ssh.password = 'vagrant'
  config.ssh.insert_key = false

you should modify sshd_config manually.

  config.vm.provision "shell", inline: <<-SHELL
     sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config    
     systemctl restart sshd.service

P.S : My English is not very good

Allow vagrant ssh to login with different usernames · Issue #1295 , It's probably a bug of the Ubuntu 14.04 vagrant box. link. I changed the public key on guest OS(./ssh/authorized_keys on guest VM Ubuntu  -p or --plain - This does an SSH without authentication, leaving authentication up to the user. » SSH client usage Vagrant will attempt to use the local SSH client installed on the host machine. On POSIX machines, an SSH client must be installed and available on the PATH. For Windows installations, an SSH client is provided within the installer image.

How to change the ssh auth method in vagrant, from password to , Some server providers, such as Amazon EC2 and Google Compute Engine, disable SSH password authentication by default. That is, you can  I've a same problem. After move machine from restore of Time Machine, on another host. There problem it's that ssh key for vagrant it's not your key, it's a key on Homestead directory. Solution for me: Use vagrant / vagrant for access ti VM of Homestead; vagrant ssh-config for see config of ssh; run on terminal

How to Enable SSH Password Authentication, SSH is not included in the Windows Installer. You need "ssh.exe" in your Windows path on the vagrant box. On the vagrant box: Install Git http://git-scm.​com/  I'd like auto login as root, but vagrant always prompt password input and authentication failure. env: centos 7 x64 Vagrant 1.8.6 Virtualbox 5.1 Vagrantfile: Vagrant.configure("2") do |config| = "ubuntu14" config.ssh.userna

Vagrant hangs on SSH auth method: password, I'd like to enable password ssh authentication (and keep key-based authentication enabled) for may Vagrant VM. How to set that? Vagrantfile : If you want to avoid the password, the easiest way is to use the SSH config file output by vagrant. The trick is to login to default not vagrant@ or vagrant@localhost. This is because the config output by ssh-config is for a host called default.

  • It Works! Thanks
  • is there a proper way to script this in ''Vagrantfile'' rather than manually configuring ssh? Btw.: You also need to restart sshd after the change (i.e. systemctl restart sshd)
  • I would add perl -i -pe 'if (/^PasswordAuthentication no$/) { s/no$/yes/; $pwdAuth = 1 ; }; if (/^PasswordAuthentication yes$/) { $pwdAuth = 1 } ; END { if (!$pwdAu th) {print "\n# activate password auth\nPasswordAuthentication yes\n"}}' /etc/ssh/sshd_config and the sshd restart command to your provision script
  • It didn't work for me. vagrant up command got stuck prompting vagrant@'s password:. I can't provide the password since it is not provided by the box author.
  • so you need to login once to the VM and set the password, then repackage the box and use the config from my post
  • maybe, according to it looks like one can't have different account and ssh passwords. I wasn't able to change account password using config.ssh.password during my experiments. So I'm really confused about the purpose of config.ssh.password.
  • you're confusing the authentication and the setting of the password. You need to have the user correctly setup already in the VM (with a password) and config.ssh.password is there to let vagrant knows which password is needed to authenticate the user. It is not there to set a new password for the user (you would first need to login to the VM to make this change)