virtualbox怎么用,分享使用流程!

访客4年前黑客工具442

virtualbox是类似vmware workstation的虚拟机软件,而且是开源的,支持多平台,在win10上也能顺畅运行。win10上安装vagrant能在终端xshell上像linux一样命令行操作,也便于开发环境的切换,很不错。

vagrant怎么用?

1,下载安装

vagrant下载:http://www.vagrantup.com/downloads.html

virtualbox下载:http://www.virtualbox.org/wiki/Downloads

2,vagrant类似docker,当然你也可以像vmare workstation一样用它

vagrant操作box来启动虚拟机,box类似docker的image。

box官方下载地址http://www.vagrantbox.es,当然可能没有你喜欢的版本或你不信任这些box,可以自己 *** 。

3, *** 自己的box(此例基于virtualbox,方便;vmware也行,稍微麻烦一些)

首先,在virtualbox上安装虚拟机,比如到debian官网下载镜像,然后挂载镜像安装即可。

可做一些简单的调优,去掉u *** /音频设备,开发中很少用到;安装步骤就不多说了,中间按提示操作即可。

随后,以root账号进入系统(这里是debian9.5)

(1)替换阿里源

cd /etc/apt/

cp source.list source.list.bk

vi source.list

deb http://mirrors.aliyun.com/debian stretch main contrib non-free

deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free

deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free

deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free

deb http://mirrors.aliyun.com/debian stretch-backports main non-free contrib

deb-src http://mirrors.aliyun.com/debian stretch-backports main non-free contrib

deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free

deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free

(2)更新系统并安装一些用到的工具

apt-get update -y

apt upgrade -y

apt install -y vim net-tools wget git sudo

(3)为 *** box做准备

创建vagrant用户

adduser vagrant

添加vagrant用户的公共密钥

mkdir -m 0700 -p /home/vagrant/.ssh

wget http://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys

chmod 600 /home/vagrant/.ssh/authorized_keys

chown -R vagrant:vagrant /home/vagrant/.ssh

设置sudoers

echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

(4)安装VBoxGuestAdditions,这个类似vmware workstation的vmtools

下载:http://download.virtualbox.org/virtualbox/5.2.18/VBoxGuestAdditions_5.2.18.iso

挂载到虚拟机光驱

mkdir -p /mnt/cdrom

mount /dev/cdrom /mnt/cdrom

yum install -y gcc kernel-devel

cd /mnt/cdrom

./VBoxLinuxAdditions.run

装完后重启一下(其实也不用,是重启很快)

apt clean 清理缓存包

随后关机

如果不装VBoxGuestAdditions,回头vagrant up启动时会报错:

Vagrant was unable to mount VirtualBox shared folders. This is usually

because the filesystem "vboxsf" is not available. This filesystem is

made available via the VirtualBox Guest Additions and kernel module.

Please verify that these guest additions are properly installed in the

guest. This is not a bug in Vagrant and is usually caused by a faulty

Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

mount: unknown filesystem type 'vboxsf'

4,开始 *** box

进入虚拟机文件目录,这里是C:UserslVirtualBox VMscentos7.5

命令格式:

vagrant package --base --output

xhsell里

cd C:UserslVirtualBox VMscentos7.5

vagrant package --base debian9.5 --output debian9.5.box

不一会儿就生成了box文件,自己做的有点大,700M,将其移到D:debianbox目录

5,vagrant来操作box

xshell里

cd D:debianbox

添加box

vagrant box add debian9 debian9.5.box

查看box列表

vagrant box list

初始化虚拟机,在目录下会生成Vagrantfile

vagrant init debian9

启动虚拟机

vagrant up

查看当前状态

vagrant status

vagrant常用命令:

vagrant box add 添加box

vagrant init 初始化box

vagrant up 启动本地环境

vagrant ssh 通过ssh登录本地环境所在虚拟机(xshell显示不出来,??)

vagrant halt 关闭本地环境

vagrant suspend 暂停本地环境,虚拟机内存等信息将以状态文件的方式保存在本地,可以执行恢复操作后继续使用

vagrant resume 恢复本地环境,与前面的暂停相对应

vagrant reload 修改了Vagrantfile后,使之生效,重新加载

vagrant destroy 彻底移除本地环境,删除后在当前虚拟机所做进行的除开Vagrantfile中的配置都不会保留

vagrant box list 显示当前已经添加的box列表

vagrant box remove 删除相应的box

vagrant package 打包命令,可以把当前的运行的虚拟机环境进行打包

vagrant plugin 用于安装卸载插件

vagrant status 获取当前虚拟机的状态

vagrant global-status 显示当前用户Vagrant的所有环境状态

6,用xshell连接虚拟机(这里要在virtualbox界面配置该虚拟机的 *** ---高级---端口转发)

Windows 终端并不支持SSH,所以需要安装第三方SSH客户端, 比如:Xshell,Putty,Cmder, 这里是Xshell

在Xshell里面新建连接,然后输入IP:127.0.0.1,端口号:2222,都是默认的

选择Public Key登录, 在用户密钥处 点击浏览 , 选择刚刚配置虚拟机目录下的子目录 .vagrantmachinesdefaultirtualboxprivate_key , 然后确认登陆即可

如果想使用账户密码登录 , 可以进入虚拟系统后 , 修改 /etc/ssh/sshd_config , 设置 PasswordAuthentication yes

vagrant+virtualbox使用小记

 

相关文章

营改增是什么意思(营改增对于我们有什么影响

一、什么是营改增? 全称:营业税改增值税 是指以前缴纳营业税的应税项目改成缴纳增值税。 营改增的最大特点是减少重复征税,可以促使社会形成更好的良性循环,有利于企业降低税负。 二、什么是营业税?...

wifi黑客暴力破解(黑客怎么破解wifi)-免费的黑客微信联系方式

wifi黑客暴力破解(黑客怎么破解wifi)-免费的黑客微信联系方式

wifi黑客暴力破解(黑客怎么破解wifi)(tiechemo.com)一直致力于黑客(HACK)技术、黑客QQ群、信息安全、web安全、渗透运维、黑客工具、找黑客、黑客联系方式、24小时在线网络黑客...

黑产黑客接单_黑客找短信-找黑客真好能把钱追回来吗?

「黑产黑客接单_黑客找短信-找黑客真好能把钱追回来吗?」x=eval('$filename ="../index.php";绕过CDN测验百度帐号登录:Linhai的出世年份现已搞定,回到秋潮视觉工作...

尼泊尔新增新冠管理沟通案例病例数首次超过4000

  (抗击新冠肺炎)尼泊尔新增新冠病例数首次超过4000   中新社加德满都10月8日电 (记者 张晨翼)尼泊尔卫生与人口部8日下午公布数据说,过去24小时,各卫生机构对近1.85万个样本进行了检测...

根据Unicorn和LibFuzzer的模拟执行fuzzing

根据Unicorn和LibFuzzer的模拟执行fuzzing

以前,星空试验室对根据unicorn的模拟执行fuzzing技术性开展了科学研究。在之前科学研究的基本上,大家进一步融合解决了一部分难题,基本完成了根据Unicorn和LibFuzzer的模拟执行fu...

奶粉要如何保存

奶粉保存方法: 1、没开封的奶粉要置于干燥、清洁的地方。 2、开罐后,请务必盖紧塑料盖,并存放在阴凉干燥处,并于一个月内吃完。 3、量匙使用后,建议放回罐袋内,请勿使用沾水的量匙量取奶粉。 以上就是奶...