[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost ~]# yum -y install samba samba-client
[root@localhost ~]# rpm -qi samba
Name : samba
Epoch : 0
Version : 4.6.2
Release : 12.el7_4
Architecture: x86_64
Install Date: Tue 06 Mar 2018 03:34:03 PM CST
Group : Unspecified
Size : 1932039
License : GPLv3+ and LGPLv3+
Signature : RSA/SHA256, Tue 28 Nov 2017 01:42:09 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : samba-4.6.2-12.el7_4.src.rpm
Build Date : Tue 28 Nov 2017 12:25:36 AM CST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.samba.org/
Summary : Server and Client software to interoperate with Windows machines
Description :
Samba is the standard Windows interoperability suite of programs for Linux and Unix.
备份smb.conf
[root@localhost ~]# cd /etc/samba/
[root@localhost samba]# mv smb.conf smb.conf.origin
[root@localhost samba]# vi smb.conf
[root@localhost samba]# cat smb.conf
[global]
workgroup = WORKGROUP
server string = Ted Samba Server %v
netbios name = TedSamba
security = user
passdb backend = tdbsam
[SambaFileShare]
comment = share some files
path = /app/SambaFileShare
writable = yes
browseable = yes
write list = u_samba
create mask = 0644
directory mask = 0755
创建用户
[root@localhost samba]# groupadd g_samba
[root@localhost samba]# useradd u_samba -g g_samba
[root@localhost samba]# smbpasswd -a u_samba
New SMB password:
Retype new SMB password:
Added user u_samba.
创建共享目录
[root@localhost samba]# mkdir -p /app/SambaFileShare
[root@localhost samba]#
[root@localhost samba]# chown u_samba:g_samba /app/SambaFileShare
[root@localhost samba]# chmod 777 /app/SambaFileShare/
[root@localhost samba]# systemctl restart firewalld
[root@localhost samba]# firewall-cmd --permanent --add-port=139/tcp
FirewallD is not running
[root@localhost samba]# systemctl restart firewalld
[root@localhost samba]# firewall-cmd --permanent --add-port=139/tcp
Warning: ALREADY_ENABLED: 139:tcp
success
[root@localhost samba]# firewall-cmd --permanent --add-port=445/tcp
success
[root@localhost samba]# systemctl stop firewalld
[root@localhost samba]# systemctl status firewalld
关闭SELINUX
[root@server ~]# getenforce
Enforcing
半闭SELINUX
[root@server ~]# setenforce 0
[root@localhost SambaFileShare]# systemctl restart smb
[root@localhost SambaFileShare]# systemctl status smb
● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2018-03-06 17:49:06 CST; 25s ago
Main PID: 9709 (smbd)
Status: "smbd: ready to serve connections..."
CGroup: /system.slice/smb.service
├─9709 /usr/sbin/smbd
├─9710 /usr/sbin/smbd
├─9711 /usr/sbin/smbd
└─9712 /usr/sbin/smbd
5使用
本机测试
可以使用testparm测试samba配置是否正确
[root@localhost samba]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[SambaFileShare]"
Loaded services file OK.
WARNING: You have some share names that are longer than 12 characters.
These may not be accessible to some older clients.
(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
netbios name = TEDSAMBA
server string = Ted Samba Server %v
security = USER
idmap config * : backend = tdb
[SambaFileShare]
comment = share some files
path = /app/SambaFileShare
create mask = 0644
read only = No
write list = u_samba
root用户的话,不用密码可直接查看samba服务器情况
[root@base samba]# smbclient -L localhost
Enter root's password:
[root@localhost samba]# smbclient -L localhost
Enter WORKGROUP\root's password:
Anonymous login successful
OS=[Windows 6.1] Server=[Samba 4.6.2]
Sharename Type Comment
--------- ---- -------
SambaFileShare Disk share some files
IPC$ IPC IPC Service (Ted Samba Server 4.6.2)
Anonymous login successful
OS=[Windows 6.1] Server=[Samba 4.6.2]
Server Comment
--------- -------
Workgroup Master
--------- -------
Windows访问
1)在Windwos资源管理器访问 ,网络
访问路径里填上: \\${Samba服务器的IP} ,然后回车,可以看见共享的目录
\\192.168.204.130