共享虚拟机Linux文件给物理机

禁用SELinux
[root@localhost ~]# cp /etc/selinux/config /etc/selinux/config.default && cp /etc/selinux/config /etc/selinux/config.bak
[root@localhost ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost ~]# shutdown -r now # 需要重启操作系统才能生效
 
 
 
安装samba
[root@localhost ~]# yum install -y samba
 
 
 
修改samba配置文件
[root@localhost ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.default && cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@localhost ~]# vim /etc/samba/smb.conf
[global]
workgroup = SAMBA
 
[Linux]
path = /
writeable = yes
public = yes
guest ok = yes
[root@localhost ~]#
 
 
 
创建用户并设置密码
[root@localhost ~]# smbpasswd -a root
New SMB password: **********
Retype new SMB password: **********
Added user root.
[root@localhost ~]# smbpasswd -e root
Enabled user root.
[root@localhost ~]#
 
 
 
服务管理命令
[root@localhost ~]# systemctl enable smb.service # 开启自动启动服务
[root@localhost ~]# systemctl restart smb.service # 重启服务
 
 
 
按下组合快捷键【Win+R】,输入【\\192.168.*.*】,再输入用户名和密码登录即可。登录成功后物理机会记住用户名和密码,在“控制面板\所有控制面板项\凭据管理器”可以删除用户名和密码。

Copyright © 2024 码农人生. All Rights Reserved