cze*_*rny 11 passwords ssh vagrant
我想为可能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
Run Code Online (Sandbox Code Playgroud)
$ 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
Run Code Online (Sandbox Code Playgroud)
a此设置不接受密码.
我想可能是PasswordAuthentication no在输出中vagrant ssh-config.如何打开该选项?
kya*_*kya 11
在 centos 7 上,仅使用以下是不够的。通过这种方式,我猜它只是su vagrant通过密码变成了。我找不到任何为什么下面在官方网站上不起作用的原因。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.ssh.insert_key = false
end
Run Code Online (Sandbox Code Playgroud)
您应该手动修改 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
Run Code Online (Sandbox Code Playgroud)
对我来说,以下工作.您需要像往常一样ssh到vm然后编辑/etc/ssh/sshd_config.在那里,您需要设置PasswordAuthentication到yes代替no.这将允许密码验证.
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'
end
Run Code Online (Sandbox Code Playgroud)
行config.vm.provision 'shell', inline: 'echo "vagrant:a" | chpasswd'调用更改vagrant用户密码的 shell 配置(前提是该框带有名为 的预定义用户vagrant)。
那么一个人不仅可以通过vagrant ssh而且还可以连接
ssh vagrant@<vm-ip>
Run Code Online (Sandbox Code Playgroud)
如果您想对虚拟机强制进行密码身份验证,则需要在 Vagrantfile 中设置以下内容
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.ssh.insert_key = false
Run Code Online (Sandbox Code Playgroud)
您需要确保vagrant虚拟机中的用户有相应的密码。我不确定您使用的盒子,因此您需要自行验证。它适用于以下盒子:ubuntu/trusty64
| 归档时间: |
|
| 查看次数: |
10877 次 |
| 最近记录: |