如果你像我一樣想要在 Vagrant 裡面運行 Ansible 做自動化部署的工作,但是找不到怎麼把 Vagrant 預設的 ssh login with key 用以下這個方法就可以解決。

預設的 Linux 帳號密碼是 vagrant/vagrant

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.box_version = "1809.01"

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

config.vm.provider "libvirt" do |v|
v.memory = 16384
v.cpus = 16
end
end

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store