溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

CentOS7 samba 及windows映射網(wǎng)絡(luò)驅(qū)動(dòng)器,

發(fā)布時(shí)間:2020-02-29 00:53:56 來(lái)源:網(wǎng)絡(luò) 閱讀:265 作者:TONY16168 欄目:系統(tǒng)運(yùn)維

第一步:安裝samba服務(wù)
》yum install samba
第二步:?jiǎn)?dòng)samba服務(wù)
》systemctl start smb
查看samba的狀態(tài)
》systemctl status smb
看到Active就說(shuō)明在運(yùn)行中了
第三步:關(guān)閉防火墻
》systemctl stop firewalld.service //停止服務(wù)
》systemctl disable firewalld.service //關(guān)閉開(kāi)機(jī)啟動(dòng)
同時(shí)還有這一步
設(shè)置SELINUX=disabled(需要重啟電腦)

vi /etc/selinux/config文件中設(shè)置SELINUX=disabled ,然后重啟服務(wù)器。

第四步:需要添加一個(gè)用戶來(lái)訪問(wèn)文件
》useradd lcd //添加用戶
》passwd lcd? //修改密碼
創(chuàng)建samba用戶
》smbpasswd -a lcd
第五步:修改samba的配置文件
》vi /etc/samba/smb.conf //進(jìn)入配置文件
5.1將global中進(jìn)行一下全局配置更改:
? ? workgroup = WORKGROUP//定義工作組,也就是windows中的工作組概念
security = user //安全認(rèn)證方式采用user方式
ntlm auth = yes //否則windows7訪問(wèn)用戶會(huì)認(rèn)證失敗
5.2在conf中添加新的用戶配置(讓4的配置生效)
[lcd]
? ? ? ? path = /cloud/lcd? ?//共享目錄
? ? ? ? browsable =yes? ?
? ? ? ? writable = yes? ? ?//目錄可讀可寫(xiě)
? ? ? ? read only = no
修改后的smb.conf如下:
[global]
? ? ? ? workgroup = WORKGROUP
? ? ? ? security = user
? ? ? ? passdb backend = tdbsam
? ? ? ? printing = cups
? ? ? ? printcap name = cups
? ? ? ? load printers = yes
? ? ? ? cups options = raw
? ? ? ? ntlm auth = yes
[homes]
? ? ? ? comment = Home Directories
? ? ? ? valid users = %S, %D%w%S
? ? ? ? browseable = No
? ? ? ? read only = No
? ? ? ? inherit acls = Yes
[printers]
? ? ? ? comment = All Printers
? ? ? ? path = /var/tmp
? ? ? ? printable = Yes
? ? ? ? create mask = 0600
? ? ? ? browseable = No
[print$]
? ? ? ? comment = Printer Drivers
? ? ? ? path = /var/lib/samba/drivers
? ? ? ? write list = @printadmin root
? ? ? ? force group = @printadmin
? ? ? ? create mask = 0664
? ? ? ? directory mask = 0775
[lcd]
? ? ? ? path = /cloud/lcd
? ? ? ? browsable =yes
? ? ? ? writable = yes
? ? ? ? read only = no
第六步:設(shè)置想要共享目錄的文件權(quán)限
給共享目錄添加寫(xiě)權(quán)限,這樣可以從windows向linux中寫(xiě)入文件。比如我這里設(shè)置\home為共享目錄,那在終端輸入以下命令即可
chmod -R 777 /cloud/lcd (可寫(xiě) w=4 可讀 r=2? 可執(zhí)行 x=1 )
第七步:重啟samba服務(wù)
》systemctl restart smb

測(cè)試及使用:
win7:\10.xx.xx.xx\lcd? ?提示輸入賬號(hào)密碼。
————————————————
版權(quán)聲明:本文為CSDN博主「sparrowwf」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/sparrowwf/article/details/81064318


先掛載好CentOS光盤(pán)文件

[root@localhost /]# yum install samba
[root@localhost /]useradd -s /sbin/nologin jitai1
[root@localhost /]smbpasswd -a jitai1

[root@localhost /]# vi /etc/samba/smb.conf
[root@localhost /]# cat /etc/samba/smb.conf

[global]

workgroup = SAMBA

    workgroup = WORKGROUP 
    security = user
    ntlm auth = yes
    passdb backend = tdbsam

    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw

[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes

[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No

[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775

[jitai1]
comment = jitai1
path = /tmp/jitai1
browsable = yes
writable = yes
read only = no

win 10 即可網(wǎng)絡(luò)驅(qū)動(dòng)器映射jitai1目錄。
win10的記事本,輸入如下,保存為startupZ.bat文件
net use Z: \10.24.11.93\jitai1 jitai1 /user:jitai1 /persistent:yes

1.首先在電腦的左下角,點(diǎn)擊開(kāi)始菜單,在菜單中選擇“運(yùn)行”選項(xiàng)。
2.然后在運(yùn)行窗口中輸入“shell:startup”,點(diǎn)擊確定。
3.此時(shí)打開(kāi)的文件夾窗口就是“windows10啟動(dòng)”界面。
4.將startupZ.bat 放入該目錄,開(kāi)機(jī)自動(dòng)映射網(wǎng)絡(luò)驅(qū)動(dòng)器。

A服務(wù)器10.24.11.93:
[root@cent7x64 ~]# ssh-keygen -t rsa
[root@cent7x64 ~]# cat ~/.ssh/id_rsa.pub
[root@cent7x64 ~]# scp id_rsa.pub root@10.24.11.91:/root/.ssh/authorized_keys

B服務(wù)器10.24.11.91:
[root@cent7x64 ~]# ssh-keygen -t rsa
[root@cent7x64 ~]# cat ~/.ssh/id_rsa.pub
[root@cent7x64 ~]# scp id_rsa.pub root@10.24.11.93:/root/.ssh/authorized_keys

從10.24.11.93拷貝文件到10.24.11.91:
[root@cent7x64 ~]cat bakjitai1.sh
#!/bin/bash
scp -r /tmp/jitai1/ root@10.24.11.91:/tmp/jitai1date +%Y%m%ddate +%H:%M:%S

[root@localhost tmp]# cat rmrfjitai1.sh
!#/bin/bash
rm -rf /tmp/jitai1/.

[root@localhost tmp]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

For details see man 4 crontabs

Example of job definition:

.---------------- minute (0 - 59)

| .------------- hour (0 - 23)

| | .---------- day of month (1 - 31)

| | | .------- month (1 - 12) OR jan,feb,mar,apr ...

| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

| | | | |

* user-name command to be executed

/2 * root /tmp/bakjitai1.sh

/3 * root /tmp/rmrfjitai1.sh

定時(shí)拷貝就不用密碼驗(yàn)證了。

向AI問(wèn)一下細(xì)節(jié)
AI