我想为may Vagrant VM启用密码ssh身份验证(并保持启用基于密钥的身份验证)。如何设置?
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "fedora/26-cloud-base"
config.vm.box_version = "20170705"
config.ssh.username = 'vagrant'
config.ssh.password = 'a'
config.ssh.keys_only = false
end$ sudo vagrant ssh-config
Host default
HostName 192.168.121.166
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此设置不接受密码a。
我猜在vagrant ssh-config的输出中可能是PasswordAuthentication no。如何打开该选项?
发布于 2019-12-04 15:14:59
在centos 7上,仅使用以下代码是不够的。通过这种方式,我猜它只是让su vagrant变成了密码。我找不到任何原因,为什么下面不能在official site中工作。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.ssh.insert_key = false
end您应该手动修改sshd_config。
config.vm.provision "shell", inline: <<-SHELL
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd.service
SHELL发布于 2018-03-25 23:57:45
对我来说,下面的方法是可行的。您需要像往常一样通过ssh访问vm,然后编辑/etc/ssh/sshd_config。在这里,您需要将PasswordAuthentication设置为yes而不是no。这将允许密码身份验证。
发布于 2017-08-24 01:34:16
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "fedora/26-cloud-base"
config.vm.box_version = "20170705"
config.vm.provision 'shell', inline: 'echo "vagrant:a" | chpasswd'
endLine config.vm.provision 'shell', inline: 'echo "vagrant:a" | chpasswd'调用shell provisioning来更改vagrant用户的密码(前提是该框附带了名为vagrant的预定义用户)。
这样不仅可以通过vagrant ssh连接,而且还可以
ssh vagrant@<vm-ip>https://stackoverflow.com/questions/45841206
复制相似问题