搭建实验环境:
服务器部分:
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:26:05:59
inet addr:1.1.1.1 Bcast:1.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe26:559/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:6264 (6.1 KiB)
Interrupt:59 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:880 (880.0 b) TX bytes:880 (880.0 b)
客户机部分:
[root@localhost /]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:26:05:59
inet addr:1.1.1.2 Bcast:1.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe26:559/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:147 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:23792 (23.2 KiB)
Interrupt:59 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:900 (900.0 b) TX bytes:900 (900.0 b)
搭建服务:
1、安装samba
[root@localhost /]# yum -y install samba
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Server | 1.3 kB 00:00
Server/primary | 753 kB 00:00
Server 2348/2348
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package samba.i386 0:3.0.33-3.28.el5 set to be updated
--> Processing Dependency: perl(Convert::ASN1) for package: samba
--> Running transaction check
---> Package perl-Convert-ASN1.noarch 0:0.20-1.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
samba i386 3.0.33-3.28.el5 Server 16 M
Installing for dependencies:
perl-Convert-ASN1 noarch 0.20-1.1 Server 41 k
Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 16 M
Downloading Packages:
--------------------------------------------------------------------------------
Total 1.4 GB/s | 16 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Convert-ASN1 1/2
error: failed to stat /media/RHEL_5.5 i386 DVD: 没有那个文件或目录
Installing : samba 2/2
Installed:
samba.i386 0:3.0.33-3.28.el5
Dependency Installed:
perl-Convert-ASN1.noarch 0:0.20-1.1
Complete!
2、为各部门建立目录
[root@localhost /]# mkdir -p /var/share/public
[root@localhost /]# mkdir -p /var/share/training
[root@localhost /]# mkdir -p /var/share/devel
3、建立用户和组
[root@localhost ~]# groupadd tech
[root@localhost ~]# groupadd dachuan
[root@localhost ~]# useradd gao01
[root@localhost ~]# useradd tec01
[root@localhost ~]# useradd ben01
[root@localhost ~]# usermod -g tech tec01
[root@localhost ~]# usermod -g dachuan ben01
4、添加samba用户
[root@localhost ~]# smbpasswd -a gao01
New SMB password:
Retype new SMB password:
Added user gao01.
[root@localhost ~]# smbpasswd -a tec01
New SMB password:
Retype new SMB password:
Added user tec01.
[root@localhost ~]# smbpasswd -a ben01
New SMB password:
Retype new SMB password:
Added user ben01.
[root@localhost ~]# smbpasswd -a root
New SMB password:
Retype new SMB password:
Added user root.
5、确认映射表中是否 root=admin
[root@localhost /]# cat /etc/samba/smbusers
# Unix_name = SMB_name1 SMB_name2 ...
root = administrator admin
nobody = guest pcguest smbguest
6、设置相关权限
[root@localhost share]# chmod 775 devel
[root@localhost share]# ll
总计 24
drwxrwxr-x 2 root root 4096 03-10 01:25 devel
drwxr-xr-x 2 root root 4096 03-10 01:24 public
drwxr-xr-x 2 root root 4096 03-10 01:24 training
7、编辑配置文件
[root@localhost /]# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@localhost /]# grep -v "^#" /etc/samba/smb.conf.bak | grep -v "^;" | grep -v "^$" > /etc/samba/smb.conf
[root@localhost /]# vim /etc/samba/smb.conf
[global]
workgroup = MYGROUP
server string = Samba Server
security = share
passdb backend = tdbsam
load printers = yes
cups options = raw
username map = /etc/samba/smbusers
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[public]
comment = Public
path = /var/share/public
public = yes
read only = yes
[peixun]
comment = Technical
path = /var/share/training
public = no
read only = yes
valid users = root, @tech
[kaifa]
comment = Development
path = /var/share/devel
public = no
writable = yes
valid users = root, @dachuan, @tech
directory mask = 0744
create mask = 0600
8、安装完成
[root@localhost /]# service smb restart
关闭 SMB 服务: [失败]
关闭 NMB 服务: [失败]
启动 SMB 服务: [确定]
启动 NMB 服务: [确定]
9、进行验证
[root@localhost ~]# smbclient -L 1.1.1.1
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]
Sharename Type Comment
--------- ---- -------
public Disk Public
peixun Disk Technical
kaifa Disk Development
IPC$ IPC IPC Service (Samba Server)
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]
Server Comment
--------- -------
LOCALHOST Samba Server
Workgroup Master
--------- -------
MYGROUP LOCALHOST
MYGROUP LOCALHOST
[root@localhost ~]# smbclient -U gao01 //1.1.1.1/public
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]
Server not using user level security and no password supplied.
smb: \> dir
NT_STATUS_ACCESS_DENIED listing \*
37445 blocks of size 524288. 30126 blocks available
smb: \> mkdir aa
NT_STATUS_MEDIA_WRITE_PROTECTED making remote directory \aa
[root@localhost ~]# smbclient -U gao01 //1.1.1.1/peixun
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]
Server not using user level security and no password supplied.
tree connect failed: NT_STATUS_WRONG_PASSWORD
转载于:https://blog.51cto.com/tibet/1151070