Linux伺服器---安裝samba
阿新 • • 發佈:2018-12-13
安裝samba
1、檢測samba是否安裝,如果沒有,那麼可以使用yum來安裝。至少需要安裝3個軟體:samba, samba-client、samba-common
[[email protected] pub]# rpm -qa | grep samba
samba-winbind-clients-3.6.9-164.el6.i686
samba-client-3.6.9-164.el6.i686
samba-common-3.6.9-164.el6.i686
samba4-libs-4.0.0-58.el6.rc4.i686
samba-winbind-3.6.9-164.el6.i686
[[email protected] pub]# yum install –y samba samba-client samba-common //如果沒有,那麼可以用此命令安裝
2、建立共享目錄
[[email protected] /]# mkdir /wj //建立目錄
[[email protected] /]# chmod 777 /wj //設定許可權
3、修改配置檔案“/etc/samba/smb.cnf”
[ [email protected] /]#
gedit /etc/samba/smb.conf
# ----------------------- Standalone Server Options ------------------------
# Scurity can be set to user, share(deprecated) or server(deprecated)
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration
security = share //這裡預設是user,改為share,這樣不用輸入密碼就可訪問
passdb backend = tdbsam
[wj] //建立共享目錄配置
comment=wj //名字
path=/wj //路徑
read only=no //是否只讀,這裡為no,這樣使用者就可以建立資料夾
guest ok=yes //是否允許guest使用者登入
browseable=yes //是否可以瀏覽目錄
4、修改防火牆,開啟tcp的埠137、138、139、445
[[email protected] wj]# gedit /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
[[email protected] wj]# service iptables restart
iptables:將鏈設定為政策 ACCEPT:filter nat [確定]
iptables:清除防火牆規則: [確定]
iptables:正在解除安裝模組: [確定]
iptables:應用防火牆規則: [確定]
iptables:載入額外模組:nf_conntrack_ftp [確定]
5、啟動smb服務
[[email protected] wj]# service smb start
啟動 SMB 服務: [確定]
6、測試,在終端輸入命令“testparm”,可以看到共享目錄的資訊
[[email protected] wj]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[wj]"
WARNING: The security=share option is deprecated
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
security = SHARE
log file = /var/log/samba/log.%m
max log size = 50
idmap config * : backend = tdb
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
browseable = No
[wj]
comment = wj //名字
path = /wj //路徑
read only = No //是否只讀
guest ok = Yes //是否允許guest訪問
7、從windows測試,按下快捷鍵“window+r”,在彈出的視窗輸入命令“smb:\\192.168.0.113”,可以看到本機的共享目錄
1、檢測samba是否安裝,如果沒有,那麼可以使用yum來安裝。至少需要安裝3個軟體:samba, samba-client、samba-common
[[email protected] pub]# rpm -qa | grep samba
samba-winbind-clients-3.6.9-164.el6.i686
samba-client-3.6.9-164.el6.i686
samba-common-3.6.9-164.el6.i686
samba4-libs-4.0.0-58.el6.rc4.i686
samba-winbind-3.6.9-164.el6.i686
[[email protected] pub]# yum install –y samba samba-client samba-common //如果沒有,那麼可以用此命令安裝
2、建立共享目錄
[[email protected] /]# mkdir /wj //建立目錄
[[email protected] /]# chmod 777 /wj //設定許可權
3、修改配置檔案“/etc/samba/smb.cnf”
[
# ----------------------- Standalone Server Options ------------------------
# Scurity can be set to user, share(deprecated) or server(deprecated)
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration
security = share //這裡預設是user,改為share,這樣不用輸入密碼就可訪問
passdb backend = tdbsam
[wj] //建立共享目錄配置
comment=wj //名字
path=/wj //路徑
read only=no //是否只讀,這裡為no,這樣使用者就可以建立資料夾
guest ok=yes //是否允許guest使用者登入
browseable=yes //是否可以瀏覽目錄
4、修改防火牆,開啟tcp的埠137、138、139、445
[[email protected] wj]# gedit /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
[[email protected] wj]# service iptables restart
iptables:將鏈設定為政策 ACCEPT:filter nat [確定]
iptables:清除防火牆規則: [確定]
iptables:正在解除安裝模組: [確定]
iptables:應用防火牆規則: [確定]
iptables:載入額外模組:nf_conntrack_ftp [確定]
5、啟動smb服務
[[email protected] wj]# service smb start
啟動 SMB 服務: [確定]
6、測試,在終端輸入命令“testparm”,可以看到共享目錄的資訊
[[email protected] wj]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[wj]"
WARNING: The security=share option is deprecated
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
security = SHARE
log file = /var/log/samba/log.%m
max log size = 50
idmap config * : backend = tdb
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
browseable = No
[wj]
comment = wj //名字
path = /wj //路徑
read only = No //是否只讀
guest ok = Yes //是否允許guest訪問
7、從windows測試,按下快捷鍵“window+r”,在彈出的視窗輸入命令“smb:\\192.168.0.113”,可以看到本機的共享目錄