使用 vagrant 的好一個好處就是能夠想協做中分享咱們的 Boxhtml
下面就介紹一下打包方式git
首先肯定須要打包哪臺虛擬機,進入安裝 VirtualBox 的安裝目錄github
默認在這個路徑
C:\Program Files\Oracle\VirtualBox
cd "C:\Program Files\Oracle\VirtualBox"
查看全部的虛擬機,能夠看到有顯示格式以下: "vmname" {vmid}
,咱們這裏須要的是 vmname
shell
> ./VBoxManage.exe list vms "django-twitter_default_1619620682201_12310" {b3c74405-5d50-4f05-9f0e-98c9563f1fa5}
將目標切換到你須要的路徑中,而後執行如下的目錄django
vagrant package --base django-twitter_default_1619620682201_12310 --output demo_ubuntu18.box
好了,這個時候你的路徑下就會生成一個 demo_ubuntu18.box
的文件ubuntu
光有打包是不夠的,由於打包的目的是爲了使用 box 鏡像。使用的時候有兩個注意點,那就是由於 ssh 密鑰的緣故,你 add ,而後 up 以後會發現進不去,這是就須要去修改 vagrantfile 這個文件,將默認的密鑰登陸改成帳號密碼登陸。安全
ssh 密鑰錯誤以下app
> vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'hashicorp/bionic64_demo_ubuntu18'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: twitter-term-1_default_1623336326135_46711 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: You are trying to forward to privileged ports (ports <= 1024). Most ==> default: operating systems restrict this to only privileged process (typically ==> default: processes running as an administrative user). This is a warning in case ==> default: the port forwarding doesn't work. If any problems occur, please try a ==> default: port higher than 1024. ==> default: Forwarding ports... default: 8000 (guest) => 80 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong. If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly, as well. If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.
可是帳號密碼登陸不如密鑰登陸安全,因此第一次(帳號+密碼)登陸以後,建議改成密鑰登錄
若是你尚未 vagrantfile
文件,才須要初始化操做ssh
你能夠複用老虛擬機的vagrantfile
文件,或者執行初始化操做新建一個vagrantfile
文件
vagrant init [box_name]
vagrant box add {box_name} {box_file_path}
利用vagrant打包系統--製做本身的box
Vagrant+Miniconda+PyCharm
Vagrant ssh authentication failure
"Warning: Authentication failure. Retrying... " after packaging box #5186ionic