1. linux redhat 中安裝samba 出現依賴關系,請教怎麼解決
mount 安裝光碟,配置好yum源到安裝光碟所在目錄,例如/mnt:
vi /etc/yum.repos.d/local.repo
配置版如下:
[Server]
name=Server
baseurl=file:///mnt/
gpgcheck=0
enabled=1
執行yum安裝:權
yum install samba*
2. redhat6.3中samba伺服器security指定為share後為什麼需要密碼登錄
Samba服務程序的配置方法跟咱們以前學習過的服務很相似,首先咱們需要先通過yum軟體倉庫來安裝samba服務程序,這款軟體也恰巧是軟體包的名字,很好記吧~:
[root@linuxprobe ~ ]# yum install samba
Loaded plugins: langpacks, proct-id, subscription-manager
………………省略部分輸出信息………………
Installing:
samba x86_64 4.1.1-31.el7 rhel 527 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 527 k
Installed size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : samba-4.1.1-31.el7.x86_64 1/1
Verifying : samba-4.1.1-31.el7.x86_64 1/1
Installed:
samba.x86_64 0:4.1.1-31.el7
Complete!
安裝後打開Samba服務程序的主配置後發現竟然有320行呢!有沒有被嚇到?但仔細一看發現其實大多都是以#(井號)開頭的注釋信息行,既然您手中已經擁有了劉遄老師的經驗之書,就肯定不會讓您去「死啃」這些東東的~:
[root@linuxprobe ~]# cat /etc/samba/smb.conf
# This is the main Samba configuration file. For detailed information about the
# options listed here, refer to the smb.conf(5) manual page. Samba has a huge
# number of configurable options, most of which are not shown in this example.
#
# The Official Samba 3.2.x HOWTO and Reference Guide contains step-by-step
# guides for installing, configuring, and using Samba:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# The Samba-3 by Example guide has working examples for smb.conf. This guide is
# generated daily: http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# In this file, lines starting with a semicolon (;) or a hash (#) are
# comments and are ignored. This file uses hashes to denote commentary and
# semicolons for parts of the file you may wish to configure.
#
# Note: Run the "testparm" command after modifying this file to check for basic
# syntax errors.
#
………………省略部分輸出信息………………
由於這次配置文件中的注釋信息行實在太多,不便於分析裡面的重要參數,因此咱們可以先將配置文件改個名字,然後使用cat命令讀入主配置文件內容後通過grep命令-v參數(反向選擇)分別去掉所有以#(井號)和;(分號)開頭的注釋信息行,對於剩餘的空白行可以再用^$來表示並反選過濾,最後將過濾後的可用參數信息通過重定向符覆蓋寫入到原始文件名稱中即可。samba服務程序過濾後的參數並不復雜,為了更方便同學們查閱參數功能,劉遄老師在重要參數行後面都寫上了注釋說明:
[root@linuxprobe ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@linuxprobe ~]# cat /etc/samba/smb.conf.bak | grep -v "#" | grep -v ";" | grep -v "^$" > /etc/samba/smb.conf
[root@linuxprobe ~]# cat /etc/samba/smb.conf
編輯
[global] #全局參數。
workgroup = MYGROUP #工作組名稱。
server string = Samba Server Version %v #伺服器介紹信息,參數%v為顯示SMB版本號。
log file = /var/log/samba/log.%m #定義日誌文件存放位置與名稱,參數%m為來訪的主機名。
max log size = 50 #定義日誌文件最大容量為50Kb。
security = user #安全驗證的方式,總共有4種。
#share:來訪主機無需驗證口令,更加方便,但安全性很差。
#user:需由SMB服務驗證來訪主機提供的口令後才可建立訪問,更加的安全。
#server:使用獨立的遠程主機驗證來訪主機提供的口令(集中管理帳號)。
#domain:使用PDC來完成驗證
passdb backend = tdbsam #定義用戶後台的類型,共有3種。
#smbpasswd:使用SMB服務的smbpasswd命令給系統用戶設置SMB密碼。
#tdbsam:創建資料庫文件並使用pdbedit建立SMB獨立的用戶。
#ldapsam:基於LDAP服務進行帳戶驗證。
load printers = yes #設置是否當Samba服務啟動時共享列印機設備。
cups options = raw #列印機的選項
[homes] #共享參數
comment = Home Directories #描述信息
browseable = no #指定共享是否在「網上鄰居」中可見。
writable = yes #定義是否可寫入操作,與"read only"相反。
[printers] #列印機共享參數
comment = All Printers
path = /var/spool/samba #共享文件的實際路徑(重要)。
browseable = no
guest ok = no #是否所有人可見,等同於"public"參數。
writable = no
printable = yes
12.1.1 配置共享資源
Samba服務程序的配置文件與前面學習過的Apache服務很相似,包括有全局配置參數和局部配置參數,全局配置參數是Samba服務程序對整體共享環境的設置,是對裡面每個獨立的共享資源都生效的參數,而區域配置參數指的則是一個個獨立可用的共享資源,共享資源的創建方法很簡單,只需要按照下面參數格式寫入配置文件後重啟服務程序即可~
編輯
參數 作用
[linuxprobe] 共享名稱為linuxprobe
comment = Do not arbitrarily modify the database file 警告用戶不要隨意修改資料庫
path = /home/database 共享文件夾在/home/database
public = no 關閉所有人可見
writable = yes 允許寫入操作
第1步:創建用於訪問共享資源的帳戶信息,在紅帽RHEL7系統中Samba服務程序默認使用的是用戶口令認證模式(user),可以做到僅讓有密碼、受信任的用戶訪問共享資源,驗證的過程也十分的簡單。不過咱們需要為Samba服務程序建立獨立的用戶密碼資料庫後才能登陸使用,另外Samba服務的資料庫要求帳號必須是當前系統中已經存在的用戶,否則日後創建文件將產生許可權屬性的混亂錯誤。
pdbedit命令用於管理SMB服務的帳戶信息資料庫,格式為:「pdbedit [選項] 帳戶」,當第一次將用戶信息寫入到資料庫時需要使用-a參數,以後修改用戶密碼、刪除用戶等等操作就不再需要了:
編輯
參數 作用
-a 用戶名 建立Samba用戶
-x 用戶名 刪除Samba用戶
-L 列出用戶列表
-Lv 列出用戶詳細信息的列表
[root@linuxprobe ~]# id linuxprobe
uid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe)
[root@linuxprobe ~]# pdbedit -a -u linuxprobe
new password:此處輸入該用戶在Samba服務資料庫中的密碼
retype new password:再次輸入密碼進行確認
Unix username: linuxprobe
NT username:
Account Flags: [U ]
User SID: S-1-5-21-507407404-3243012849-3065158664-1000
Primary Group SID: S-1-5-21-507407404-3243012849-3065158664-513
Full Name: linuxprobe
Home Directory: \\localhost\linuxprobe
HomeDir Drive:
Logon Script:
Profile Path: \\localhost\linuxprobe\profile
Domain: LOCALHOST
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: Wed, 06 Feb 2036 10:06:39 EST
Kickoff time: Wed, 06 Feb 2036 10:06:39 EST
Password last set: Mon, 13 Mar 2017 04:22:25 EDT
Password can change: Mon, 13 Mar 2017 04:22:25 EDT
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours :
第2步:創建用於共享資源的文件目錄,同學們不光要考慮到文件訪問和寫入許可權的問題,而且由於/home目錄是系統中普通用戶的家目錄,因此咱們還需要考慮到文件上面SELinux安全上下文的監管控制,實際上剛剛過濾掉的注釋信息中就提醒有了相關的SELinux安全上下文策略的說明,咱們只需要按照給的值進行修改即可,最後再記得執行下restorecon命令讓目錄文件上面新設置的SELinux安全上下文立即生效下哦~
[root@linuxprobe ~]# mkdir /home/database
[root@linuxprobe ~]# chown -Rf linuxprobe:linuxprobe /home/database
[root@linuxprobe ~]# semanage fcontext -a -t samba_share_t /home/database
[root@linuxprobe ~]# restorecon -Rv /home/database
restorecon reset /home/database context unconfined_u:object_r:home_root_t:s0->unconfined_u:object_r:samba_share_t:s0
第3步:設置SELinux服務對Samba程序訪問個人用戶家目錄的允許策略,過濾篩選出所有與samba服務程序相關的SELinux域策略,根據策略的名稱和咱們的經驗選擇出合適的策略條目進行開啟即可:
[root@localhost ~]# getsebool -a | grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_sandbox_use_samba --> off
virt_use_samba --> off
[root@linuxprobe ~]# setsebool -P samba_enable_home_dirs on
具體samba服務的詳解:http://www.linuxprobe.com/chapter-12.html
3. linux samba共享文件夾許可權設置 不能復制文件
這是linux上的samba服務文來件夾許可權沒源有作設置,以redhat linux為例。
1、設置文件夾許可權,檢測配置文件,假設在samba服務配置文件中設置的公開目錄為/home/samba/share。
chmod -R 0777 /home/samba/share
testparm
2、重啟Samba服務即可解決
service smb restart