目标:搭建Samba 服务器,使得主机能够访问虚拟机的资料
环境:Oracle VM VirtualBox + Xubantu
步骤:
1.安装Samba服务器
apt-get install samba
2.新建目录share
mkdir share
3.打开Samba配置目录进行修改
vim /etc/samba/smb.conf
4.在末尾增加内容,保存退出(用户为root,用有读写权限):
[Ben]
path = /home/a/share
available = yes
browseable = yes
writable = yes
valid users = root
5.新建用户root(密码可以直接按Enter设置为空密码):
smbpasswd -a root
6.获取虚拟机IP:
ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.31.95 netmask 255.255.255.0 broadcast 192.168.31.255
inet6 fe80::a5a3:a470:4212:966b prefixlen 64 scopeid 0x20<link>
ether 08:00:27:b9:6c:1f txqueuelen 1000 (以太网)
RX packets 136393 bytes 186195307 (186.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45526 bytes 4116256 (4.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 65 bytes 8136 (8.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 65 bytes 8136 (8.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
比如我的ip是 192.168.31.95
7.windows win+E打开资源管理器,在地址栏输入\\192.168.31.95,按回车:
8.双击Ben文件夹,输入用户名和密码,保存凭证即可(空密码则不用输密码):
效果展示: