Samba
1支持软件包
samba-2.2.7a-7.9.0.i386.rpm
samba-client-2.2.7a-7.9.0.i386.rpm
#rpm-qasamba
samba-2.2.7a-7.9.0
#rpm-qasamba-client
samba-client-2.2.7a-7.9.0
2配置文件目录
#cd/etc/samba
#vismb.conf
采用默认设置,允许与主机用户同名的smb用户访问主机用户
3添加SMB用户
3.1添加系统用户,是开启本地用户。
#useraddsmbtest
#passwdsmbtest
Changingpasswordforusersmbtest.
Newpassword:
BADPASSWORD:itistoosimplistic/systematic
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
3.2既是把smbtest用户开启smb用户权限
[root@testbedsamba]#smbpasswd-asmbtest
NewSMBpassword:
RetypenewSMBpassword:
Addedusersmbtest.
4开启smb服务
#servicesmb[restart|stop|start|status]
#servicesmbrestart
关闭SMB服务:[确定]
关闭NMB服务:[确定]
启动SMB服务:[确定]
启动NMB服务:[确定]
#servicesmbstatus
smbd(pid4951)正在运行...
nmbd(pid4955)正在运行...
5本机客户端测试
命令格式:
列出主机共享资源表:#smbclient-L//主机名或主机IP-U//smb用户名
使用共享资源:#smbclient-L//主机名或主机IP/共享目录名-U//smb用户名
下面的localhost是服务器smbtest是主机共享的文件夹在/home/snbtest下是服务器提供的。
[root@testbedsamba]#smbclient-Llocalhost-Usmbtest查看本机的资源既是服务
addedinterfaceip=128.100.3.141bcast=128.100.3.255nmask=255.255.255.0
Password:
Domain=[MYGROUP]OS=[Unix]Server=[Samba2.2.7a]
SharenameTypeComment
--------------------
IPC$IPCIPCService(SambaServer)
ADMIN$DiskIPCService(SambaServer)
smbtestDiskHomeDirectories
ServerComment
----------------
TESTBEDSambaServer
WorkgroupMaster
----------------
MYGROUP
在服务器下/home/smbtest下建立一个文件test
[root@testbedsamba]#smbclient//localhost/smbtest-Usmbtest
addedinterfaceip=128.100.3.141bcast=128.100.3.255nmask=255.255.255.0
Password:
Domain=[MYGROUP]OS=[Unix]Server=[Samba2.2.7a]
smb:\>dir
.D0ThuApr1913:58:012007
..D0ThuApr1913:42:372007
.kdeDH0ThuApr1913:42:372007
.bash_logoutH24ThuApr1913:42:372007
.bash_profileH191ThuApr1913:42:372007
.bashrcH124ThuApr1913:42:372007
.emacsH847ThuApr1913:42:372007
.gtkrcH120ThuApr1913:42:372007
test8ThuApr1913:58:012007
39469blocksofsize262144.20520blocksavailable
smb:\>quit
6Windows端的测试
6.1在”网上邻居”中的”Mygroup”工作组中就可查看Linux下安装的smb服务器
6.2直接在”运行”中输入”\\服务器名或\\服务器IP地址”
6.3\\服务器IP地址-U(smb用户名)
7Linux主机上访问smb资源
命令格式:
smbmount共享资源地址加载点-o参数
smbumount加载点
[root@testbedsamba]#mkdir/mnt/smb
[root@testbedsamba]#smbmount//128.100.3.141/smbtest/mnt/smb-ousername=smbtest
Password:
[root@testbedsamba]#ls/mnt/smb
test
[root@testbedsamba]#smbumount/mnt/smb
[root@testbedsamba]#ls/mnt/smb
8特定用户访问的共享目录
[root@testbedroot]#useraddfred
[root@testbedroot]#passwdfred
Changingpasswordforuserfred.
Newpassword:
BADPASSWORD:itistooshort
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@testbedroot]#smbpasswd-afred
NewSMBpassword:
RetypenewSMBpassword:
Addeduserfred.
[root@testbedroot]#mkdir/var/samba/fred
mkdir:无法创建目录‘/var/samba/fred’:没有那个文件或目录
[root@testbedroot]#mkdir/var/samba
[root@testbedroot]#mkdir/var/samba/fred
[root@testbedroot]#echo"testfred">/var/samba/fred/test
[root@testbedroot]#vi/etc/samba/smb.conf
[fredsdir]
comment=ThisisFred''sSMBsharefolder
path=/var/samba/fred
validusers=fred#<添加多个用户名可支持多用户访问>
public=no
writable=yes
[root@testbedroot]#sercicesmbrestart
[root@testbedroot]#smbclient//128.100.3.141/fredsdir-Ufred
addedinterfaceip=128.100.3.141bcast=128.100.3.255nmask=255.255.255.0
Password:
Domain=[MYGROUP]OS=[Unix]Server=[Samba2.2.7a]
smb:\>dir
.D0ThuApr1915:02:592007
..D0ThuApr1915:02:342007
test10ThuApr1915:02:592007
39469blocksofsize262144.20524blocksavailable
smb:\>quit
[root@testbedroot]#smbclient//128.100.3.141/fredsdir-Ulxf
addedinterfaceip=128.100.3.141bcast=128.100.3.255nmask=255.255.255.0
Password:
Domain=[MYGROUP]OS=[Unix]Server=[Samba2.2.7a]
treeconnectfailed:NT_STATUS_WRONG_PASSWORD
[root@testbedroot]#smbclient//128.100.3.141/fredsdir-Usmbtest
addedinterfaceip=128.100.3.141bcast=128.100.3.255nmask=255.255.255.0
Password:
Domain=[MYGROUP]OS=[Unix]Server=[Samba2.2.7a]
treeconnectfailed:NT_STATUS_WRONG_PASSWORD
9用户组访问的目录
[root@testbedroot]#useraddstaff
[root@testbedroot]#passwdstaff
Changingpasswordforuserstaff.
Newpassword:
BADPASSWORD:itistooshort
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@testbedroot]#useradd-Gstaffuser1
[root@testbedroot]#passwduser1
Changingpasswordforuseruser1.
Newpassword:
BADPASSWORD:itistooshort
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@testbedroot]#useradd-Gstaffuser2
[root@testbedroot]#passwduser2
Changingpasswordforuseruser2.
Newpassword:
BADPASSWORD:itistooshort
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@testbedroot]#smbpasswd-auser1
NewSMBpassword:
RetypenewSMBpassword:
Addeduseruser1.
[root@testbedroot]#smbpasswd-auser2
NewSMBpassword:
RetypenewSMBpassword:
Addeduseruser2.
[root@testbedroot]#mkdir/var/samba/staff
[root@testbedroot]#chmod770/var/samba/staff
[root@testbedroot]#chownstaff.staff/var/samba/staff
[staff]
comment=Thisisstaff
path=/var/samba/staff
public=yes
writable=yes
readlist=@staff
writelist=@staff
[root@testbedroot]#servicesmbrestart
测试
[root@testbedroot]#smbclient-L//128.100.3.141-Uuser1
...
[root@testbedroot]#smbclient-L//128.100.3.141-Uuser2
...
[root@testbedroot]#smbclient//128.100.3.141/staff-Uuser2
addedinterfaceip=128.100.3.141bcast=128.100.3.255nmask=255.255.255.0
Password:
Domain=[MYGROUP]OS=[Unix]Server=[Samba2.2.7a]
smb:\>dir
.D0ThuApr1915:21:422007
..D0ThuApr1915:21:422007
39469blocksofsize262144.20523blocksavailable
smb:\>?
?altnamearchiveblocksizecancel
cdchmodchowndeldir
duexitgethelphistory
lcdlinklowercaselsmask
mdmgetmkdirmoremput
neweropenprintprintmodeprompt
putpwdqqueuequit
rdrecurserenamermrmdir
setmodesymlinktartarmodetranslate
!
smb:\>mkdirtest
smb:\>ls
.D0ThuApr1915:45:092007
..D0ThuApr1915:21:422007
testD0ThuApr1915:45:092007
39469blocksofsize262144.20523blocksavailable
smb:\>quit
关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~关于SAMBA服务~不知道对大家有没有用~
阅读(583) | 评论(0) | 转发(0) |