samba服务器怎么安装

发布时间:2021-07-10 16:06:03 作者:chen
来源:亿速云 阅读:171

这篇文章主要介绍“samba服务器怎么安装”,在日常操作中,相信很多人在samba服务器怎么安装问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”samba服务器怎么安装”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

一,安装软件

[root@station10 ~]# yum install -y samba samba-common samba-client system-config-samba

查看安装的软件

[root@station10 ~]# rpm -aq | grep samba

samba-3.0.25b-0.el5.4

system-config-samba-1.2.39-1.el5

samba-client-3.0.25b-0.el5.4

samba-common-3.0.25b-0.el5.4

[root@station10 ~]#

[@more@]

二,配置samba,方法有如下三种

1,system-config-samba

2,samba-swat(http://localhost:901)

3, 编辑 smb.conf 文件

三,通过第3中方法配置samba

1, 建立一个共享的文件夹

[root@station10 /]# mkdir /backup

[root@station10 /]# chmod 777 -R /backup

2,在/etc/samba/smb.conf末尾添加:

[backup]

comment = backup

path = /backup

writeable = yes

public = yes

printable = no

3,添加samba用户

[root@station10 /]# smbpasswd -a root

New SMB password:

Retype new SMB password:

[root@station10 /]# smbpasswd -a back

New SMB password:

Retype new SMB password:

[root@station10 /]#

4,测试语法

[root@station10 /]# testparm /etc/samba/smb.conf

Load smb config files from /etc/samba/smb.conf

Processing section "[homes]"

Processing section "[printers]"

Processing section "[backup]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

[global]

workgroup = MYGROUP

server string = Samba Server Version %v

passdb backend = tdbsam

cups options = raw

[homes]

comment = Home Directories

read only = No

browseable = No

[printers]

comment = All Printers

path = /var/spool/samba

printable = Yes

browseable = No

[backup]

comment = backup

path = /backup

read only = No

guest ok = Yes

[root@station10 /]# testparm /etc/samba/smb.conf station10.example.com 192.168.0.10

Load smb config files from /etc/samba/smb.conf

Processing section "[homes]"

Processing section "[printers]"

Processing section "[backup]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Allow connection from station10.example.com (192.168.0.10) to homes

Allow connection from station10.example.com (192.168.0.10) to printers

Allow connection from station10.example.com (192.168.0.10) to backup

[root@station10 /]#

5,启动samba

[root@station10 /]# /etc/init.d/smb start

Starting SMB services: [ OK ]

Starting NMB services: [ OK ]

[root@station10 /]#

6, 在另外一台机器上测试

[root@station12 ~]# smbclient -L station10 -U 'back%redhat'

Domain=[STATION10] OS=[Unix] Server=[Samba 3.0.25b-0.el5.4]

Sharename Type Comment

--------- ---- -------

backup Disk backup

IPC$ IPC IPC Service (Samba Server Version 3.0.25b-0.el5.4)

back Disk Home Directories

Domain=[STATION10] OS=[Unix] Server=[Samba 3.0.25b-0.el5.4]

Server Comment

--------- -------

Workgroup Master

--------- -------

MYGROUP

[root@station12 ~]#

7,建立文件夹的时候出错

[root@station12 ~]# smbclient -U 'back%redhat' //station10/backup

Domain=[STATION10] OS=[Unix] Server=[Samba 3.0.25b-0.el5.4]

smb: > ls

. D 0 Fri Oct 17 18:36:04 2008

.. D 0 Fri Oct 17 18:36:05 2008

63483 blocks of size 65536. 17042 blocks available

smb: > mkdir test

NT_STATUS_ACCESS_DENIED making remote directory test

smb: >

8,查看selinux对应的策略

# SELINUX NOTES:

#

# If you want to use the useradd/groupadd family of binaries please run:

# setsebool -P samba_domain_controller on

#

# If you want to share home directories via samba please run:

# setsebool -P samba_enable_home_dirs on

#

# If you create a new directory you want to share you should mark it as

# "samba-share_t" so that selinux will let you write into it.

# Make sure not to do that on system directories as they may already have

# been marked with othe SELinux labels.

#

# Use ls -ldZ /path to see which context a directory has

#

# Set labels only on directories you created!

# To set a label use the following: chcon -t samba_share_t /path

#

# If you need to share a system created directory you can use one of the

# following (read-only/read-write):

# setsebool -P samba_export_all_ro on

# or

# setsebool -P samba_export_all_rw on

#

# If you want to run scripts (preexec/root prexec/print command/...) please

# put them into the /var/lib/samba/scripts directory so that smbd will be

# allowed to run them.

# Make sure you COPY them and not MOVE them so that the right SELinux context

# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts

#

#--------------

9,更改selinux的策略

[root@station10 /]# chcon -t samba_share_t /backup

[root@station10 /]# /etc/init.d/smb restart

Shutting down SMB services: [ OK ]

Shutting down NMB services: [ OK ]

Starting SMB services: [ OK ]

Starting NMB services: [ OK ]

[root@station10 /]#

10,继续建立文件夹测试ok:

[root@station12 ~]# smbclient -U 'back%redhat' //station10/backup

Domain=[STATION10] OS=[Unix] Server=[Samba 3.0.25b-0.el5.4]

smb: > mkdir test

smb: > ls

. D 0 Fri Oct 17 18:44:36 2008

.. D 0 Fri Oct 17 18:36:05 2008

test D 0 Fri Oct 17 18:44:36 2008

63483 blocks of size 65536. 17042 blocks available

smb: >

11,设置简单共享

更改配置文件security 为 share

security = share

重启samba服务

[root@station10 ~]# /etc/init.d/smb restart

测试:

[root@station10 ~]# smbclient //station10/backup

Password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.0.25b-0.el5.4]

Server not using user level security and no password supplied.

smb: >

四,samba Client Tools: nmblookup

list specific machine

nmblookup -U WINS_server -R name

list all machines

nblookup *

[root@station12 ~]# nmblookup *

querying * on 192.168.0.255

192.168.0.10 *<00>

192.168.0.12 *<00>

[root@station12 ~]#

五,samba Clients Tools:mounts

The SMB and CIFS file systems are supported by the Linux Kernel

use mount to mount a Samba-shared resource:

mount -t cifs service mountpoing -o option1,option2

例子:

[root@station12 ~]# mount -t cifs //station10/backup /mnt -o username=back

Password:

[root@station12 ~]# mount

/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/mapper/VolGroup00-LogVol01 on /home type ext3 (rw)

/dev/sda1 on /boot type ext3 (rw)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

//station10/backup on /mnt type cifs (rw,mand)

[root@station12 ~]#

或者把root用户加入到samba用户

[root@station12 ~]# smbpasswd -a root

New SMB password:

Retype new SMB password:

Added user root.

[root@station12 ~]#

[root@station12 ~]# mount -t cifs //station10/backup /mnt

Password:

[root@station12 ~]# mount

/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/mapper/VolGroup00-LogVol01 on /home type ext3 (rw)

/dev/sda1 on /boot type ext3 (rw)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

//station10/backup on /mnt type cifs (rw,mand)

[root@station12 ~]#

到此,关于“samba服务器怎么安装”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

推荐阅读:
  1. centos7安装samba
  2. 安装配置Samba服务器(CentOS7)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

samba 服务器

上一篇:Python中Django和Flask框架的区别是什么

下一篇:Python中如何处理XML文件

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》