我想在我的 Vagrant 虚拟机上启用基于密码的 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
。如何打开这个选项?
perl -i -pe 'if (/^PasswordAuthentication no$/) { s/no$/yes/; $pwdAuth = 1 ; }; if (/^PasswordAuthentication yes$/) { $pwdAuth = 1 } ; END { if (!$pwdAuth) {print "\n# activate password auth\nPasswordAuthentication yes\n"}}' /etc/ssh/sshd_config
和sshd重启命令。 - bernard paulus