红联Linux门户
Linux帮助

关于SAMBA服务~不知道对大家有没有用~

发布时间:2007-04-21 10:55:09来源:红联作者:janelava
Samba
1支持软件包
samba-2.2.7a-7.9.0.i386.rpm
samba-client-2.2.7a-7.9.0.i386.rpm

# rpm -qa samba
samba-2.2.7a-7.9.0
# rpm -qa samba-client
samba-client-2.2.7a-7.9.0


2配置文件目录
#cd /etc/samba
#vi smb.conf
采用默认设置,允许与主机用户同名的smb用户访问主机用户

3添加SMB用户
3.1添加系统用户,是开启本地用户。
# useradd smbtest
# passwd smbtest
Changing password for user smbtest.
New password:
BAD PASSWORD: it is too simplistic/systematic
Retype new password:
passwd: all authentication tokens updated successfully.

3.2既是把smbtest用户开启smb用户权限
[root@testbed samba]# smbpasswd -a smbtest
New SMB password:
Retype new SMB password:
Added user smbtest.

4开启smb服务
#service smb [restart|stop|start|status]

# service smb restart
关闭 SMB 服务: [ 确定 ]
关闭 NMB 服务: [ 确定 ]
启动 SMB 服务: [ 确定 ]
启动 NMB 服务: [ 确定 ]
# service smb status
smbd (pid 4951) 正在运行...
nmbd (pid 4955) 正在运行...

5本机客户端测试
命令格式:
列出主机共享资源表:# smbclient -L//主机名或主机IP -U //smb用户名
使用共享资源:#smbclient -L//主机名或主机IP/共享目录名 -U //smb用户名




下面的localhost是服务器 smbtest是主机 共享的文件夹在/home/snbtest下 是服务器提供的。
[root@testbed samba]# smbclient -L localhost -U smbtest 查看本机的资源既是服务
added interface ip=128.100.3.141 bcast=128.100.3.255 nmask=255.255.255.0
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 2.2.7a]

Sharename Type Comment
--------- ---- -------
IPC$ IPC IPC Service (Samba Server)
ADMIN$ Disk IPC Service (Samba Server)
smbtest Disk Home Directories

Server Comment
--------- -------
TESTBED Samba Server

Workgroup Master
--------- -------
MYGROUP

在服务器下/home/smbtest下建立一个文件test
[root@testbed samba]# smbclient //localhost/smbtest -U smbtest
added interface ip=128.100.3.141 bcast=128.100.3.255 nmask=255.255.255.0
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 2.2.7a]
smb: \> dir
. D 0 Thu Apr 19 13:58:01 2007
.. D 0 Thu Apr 19 13:42:37 2007
.kde DH 0 Thu Apr 19 13:42:37 2007
.bash_logout H 24 Thu Apr 19 13:42:37 2007
.bash_profile H 191 Thu Apr 19 13:42:37 2007
.bashrc H 124 Thu Apr 19 13:42:37 2007
.emacs H 847 Thu Apr 19 13:42:37 2007
.gtkrc H 120 Thu Apr 19 13:42:37 2007
test 8 Thu Apr 19 13:58:01 2007

39469 blocks of size 262144. 20520 blocks available
smb: \> quit

6Windows端的测试
6.1在”网上邻居”中的”Mygroup”工作组中就可查看Linux下安装的smb服务器
6.2直接在”运行”中输入”\\服务器名或\\服务器IP地址”
6.3 \\服务器IP地址 -U (smb用户名)

7Linux主机上访问smb资源
命令格式:
smbmount 共享资源地址 加载点 -o 参数
smbumount 加载点


[root@testbed samba]# mkdir /mnt/smb
[root@testbed samba]# smbmount //128.100.3.141/smbtest /mnt/smb -o username=smbtest
Password:
[root@testbed samba]# ls /mnt/smb
test
[root@testbed samba]# smbumount /mnt/smb
[root@testbed samba]# ls /mnt/smb

8特定用户访问的共享目录
[root@testbed root]# useradd fred
[root@testbed root]# passwd fred
Changing password for user fred.
New password:
BAD PASSWORD: it is too short
Retype new password:
passwd: all authentication tokens updated successfully.
[root@testbed root]# smbpasswd -a fred
New SMB password:
Retype new SMB password:
Added user fred.
[root@testbed root]# mkdir /var/samba/fred
mkdir: 无法创建目录‘/var/samba/fred’: 没有那个文件或目录
[root@testbed root]# mkdir /var/samba
[root@testbed root]# mkdir /var/samba/fred
[root@testbed root]# echo "test fred">/var/samba/fred/test
[root@testbed root]# vi /etc/samba/smb.conf

[fredsdir]
comment=This is Fred's SMB share folder
path=/var/samba/fred
valid users =fred #<添加多个用户名可支持多用户访问>
public = no
writable=yes

[root@testbed root]# sercice smb restart
[root@testbed root]# smbclient //128.100.3.141/fredsdir -U fred
added interface ip=128.100.3.141 bcast=128.100.3.255 nmask=255.255.255.0
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 2.2.7a]
smb: \> dir
. D 0 Thu Apr 19 15:02:59 2007
.. D 0 Thu Apr 19 15:02:34 2007
test 10 Thu Apr 19 15:02:59 2007

39469 blocks of size 262144. 20524 blocks available
smb: \> quit
[root@testbed root]# smbclient //128.100.3.141/fredsdir -U lxf
added interface ip=128.100.3.141 bcast=128.100.3.255 nmask=255.255.255.0
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 2.2.7a]
tree connect failed: NT_STATUS_WRONG_PASSWORD
[root@testbed root]# smbclient //128.100.3.141/fredsdir -U smbtest
added interface ip=128.100.3.141 bcast=128.100.3.255 nmask=255.255.255.0
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 2.2.7a]
tree connect failed: NT_STATUS_WRONG_PASSWORD


9用户组访问的目录
[root@testbed root]# useradd staff
[root@testbed root]# passwd staff
Changing password for user staff.
New password:
BAD PASSWORD: it is too short
Retype new password:
passwd: all authentication tokens updated successfully.
[root@testbed root]# useradd -G staff user1
[root@testbed root]# passwd user1
Changing password for user user1.
New password:
BAD PASSWORD: it is too short
Retype new password:
passwd: all authentication tokens updated successfully.
[root@testbed root]# useradd -G staff user2
[root@testbed root]# passwd user2
Changing password for user user2.
New password:
BAD PASSWORD: it is too short
Retype new password:
passwd: all authentication tokens updated successfully.
[root@testbed root]# smbpasswd -a user1
New SMB password:
Retype new SMB password:
Added user user1.
[root@testbed root]# smbpasswd -a user2
New SMB password:
Retype new SMB password:
Added user user2.
[root@testbed root]# mkdir /var/samba/staff
[root@testbed root]# chmod 770 /var/samba/staff
[root@testbed root]# chown staff.staff /var/samba/staff


[staff]
comment=This is staff
path=/var/samba/staff
public=yes
writable=yes
read list=@staff
write list=@staff

[root@testbed root]# service smb restart

测试
[root@testbed root]# smbclient -L //128.100.3.141 -U user1
...
[root@testbed root]# smbclient -L //128.100.3.141 -U user2
...
[root@testbed root]# smbclient //128.100.3.141/staff -U user2
added interface ip=128.100.3.141 bcast=128.100.3.255 nmask=255.255.255.0
Password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 2.2.7a]
smb: \> dir
. D 0 Thu Apr 19 15:21:42 2007
.. D 0 Thu Apr 19 15:21:42 2007

39469 blocks of size 262144. 20523 blocks available
smb: \> ?
? altname archive blocksize cancel
cd chmod chown del dir
du exit get help history
lcd link lowercase ls mask
md mget mkdir more mput
newer open print printmode prompt
put pwd q queue quit
rd recurse rename rm rmdir
setmode symlink tar tarmode translate
!
smb: \> mkdir test
smb: \> ls
. D 0 Thu Apr 19 15:45:09 2007
.. D 0 Thu Apr 19 15:21:42 2007
test D 0 Thu Apr 19 15:45:09 2007

39469 blocks of size 262144. 20523 blocks available
smb: \> quit
文章评论

共有 56 条评论

  1. 60.197.106.* 于 2007-07-17 17:00:05发表:

    http://b67b239c4f9d645b942a6c24b6142255-t.xkktxb.org b67b239c4f9d645b942a6c24b6142255 http://b67b239c4f9d645b942a6c24b6142255-b1.xkktxb.org b67b239c4f9d645b942a6c24b6142255 http://b67b239c4f9d645b942a6c24b6142255-b3.xkktxb.org 8d1f2bfe3cbc5359328d95464cab8b7c

  2. 217.217.15.* 于 2007-07-17 17:00:01发表:

    http://b67b239c4f9d645b942a6c24b6142255-t.xkktxb.org b67b239c4f9d645b942a6c24b6142255 http://b67b239c4f9d645b942a6c24b6142255-b1.xkktxb.org b67b239c4f9d645b942a6c24b6142255 http://b67b239c4f9d645b942a6c24b6142255-b3.xkktxb.org 8d1f2bfe3cbc5359328d95464cab8b7c