文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

samba服务器怎么安装

2023-06-04 20:49

关注

这篇文章主要介绍“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服务器怎么安装”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-服务器
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯