准备工作:

确保机器中有 samba 包

# rpm -qa | grep samba
samba-client-3.5.10-125.el6.i686
samba4-libs-4.0.0-23.alpha11.el6.i686
samba-common-3.5.10-125.el6.i686
samba-winbind-clients-3.5.10-125.el6.i686
samba-3.5.10-125.el6.i686

如果系统中没有 samba 软件包,那么我们可以使用以下命令安装它

# yum -y install samba

尝试使用 Windows 客户端访问 samba 共享

我的服务器 IP 是 10.10.10.19

地址列输入 10.10.10.19

如何在 Linux 中创建 samba 共享

Samba 服务器用作域控制器以及创建可用于在 Windows 和 Linux 之间传输数据的网络共享。

注意:确保在进行任何更改之前备份所有配置文件

设置访问时密码

使预定义用户可以访问 samba 共享 (jack)

# vi /etc/samba/smb.conf

(删除所有行并输入以下内容)

security = user
workgroup = EXAMPLE
hosts allow 127. 10.10.10. 192.168.0.

[profiles]
path = /profiles
writable = yes
create mode = 0770
directory mode = 0770
share modes = yes
guest ok = no
valid users = jack

将 samba 密码分配给用户

# smbpasswd -a (username) 
New SMB password:
Retype new SMB password:

重启

# service smb restart
# service nmb restart

检查防火墙和 selinux 设置

我已两者都禁用了。

# service iptables stop

在修改 selinux 配置文件之后,我们必须重新启动机器

# vi /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=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

重启samba服务器服务

# service smb restart
# service nmb restart

使任何用户都可以访问 samba 共享

# vi /etc/samba/smb.conf
(删除所有行并输入以下内容)

security = share
workgroup = EXAMPLE
hosts allow 127. 10.10.10. 192.168.0.

[profiles]
path = /profiles
share modes = yes
guest only = yes
browseable = yes
writable = yes
guest ok = yes
create mode = 0777
directory mode = 0777
日期:2020-06-02 22:16:58 来源:oir作者:oir