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

访客4年前黑客工具438

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使用小记

 

相关文章

iPhone内存不够用怎么办(iphone运行内存不足怎么清理)

  当运用iPhone时,一旦它被运用了很长期性,手机的记忆能力便会一开始修补。尤其是一些运存小的手机经常会收到存储空间不足的提醒。那么,iPhone如何清除手机运行内存,为手机上空中出很多室内空间设...

机器人教育课程编程学什么(少儿编程与机器人

机器人教育课程编程学什么(少儿编程与机器人

有一些家长还在犹豫和迷茫中,究竟什么是机器人教育,孩子究竟需不需要学习机器人编程课程呢? 孩子上幼儿园的时候,你说孩子还太小,先让孩子学学唱歌、跳舞之类的兴趣班吧,其实孩子的创意开发时机正从你身边慢...

seo又很好学吗?基本上每一个站长都是会问起这个问题

seo又很好学吗?seo简单吗?seo赚钱吗?近期在群里常常见到这类难题,一时间感觉这种难题非常值得每一个提升人去思索,就在今天来讲本人对seo的了解还并不是很深入,都没有运用seo赚到要多少钱。可以...

qq技术论坛,怎样能联系上勒索病毒黑客,找黑客黑微博

BurpExtender.java咱们前面讲过,重点是doPassiveScan函数。 调用了FuzzVul东西类, private void ShowPort(HttpContext...

女的在同一个地方有很多开房记录能说明什么吗?-黑客帝国1和2有联系吗

function chooseTab() {iTunes备份:加密和密码Cloud Atlas主要针对东欧和中亚发起攻击。 攻击者使用简单有效的鱼叉式钓鱼攻击来入侵目标。 与其他入侵集不同,Cloud...

狗狗六个月训练好不好(狗狗训练黄金时期是什

狗狗六个月训练好不好(狗狗训练黄金时期是什

狗狗几个月训练,想要训练狗狗最好是在狗狗幼年犬的时候,小的时候狗狗比较容易驯服,而且容易纠正它们不好的习惯。但是由于狗狗比较小,所以狗狗的自觉性还有领悟能力不是特别好,家长需要多花点耐心去训练它们。狗...