CentOS7samba及windows映射网络驱动器,-创新互联

第一步:安装samba服务
》yum install samba
第二步:启动samba服务
》systemctl start smb
查看samba的状态
》systemctl status smb
看到Active就说明在运行中了
第三步:关闭防火墙
》systemctl stop firewalld.service //停止服务
》systemctl disable firewalld.service //关闭开机启动
同时还有这一步
设置SELINUX=disabled(需要重启电脑)

创新互联技术团队十多年来致力于为客户提供成都做网站、网站设计、成都品牌网站建设营销型网站建设、搜索引擎SEO优化等服务。经过多年发展,公司拥有经验丰富的技术团队,先后服务、推广了超过千家网站,包括各类中小企业、企事单位、高校等机构单位。

vi /etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器。

第四步:需要添加一个用户来访问文件
》useradd lcd //添加用户
》passwd lcd  //修改密码
创建samba用户
》smbpasswd -a lcd
第五步:修改samba的配置文件
》vi /etc/samba/smb.conf //进入配置文件
5.1将global中进行一下全局配置更改:
    workgroup = WORKGROUP//定义工作组,也就是windows中的工作组概念
security = user //安全认证方式采用user方式
ntlm auth = yes //否则windows7访问用户会认证失败
5.2在conf中添加新的用户配置(让4的配置生效)
[lcd]
        path = /cloud/lcd   //共享目录
        browsable =yes   
        writable = yes     //目录可读可写
        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
第六步:设置想要共享目录的文件权限
给共享目录添加写权限,这样可以从windows向linux中写入文件。比如我这里设置\home为共享目录,那在终端输入以下命令即可
chmod -R 777 /cloud/lcd (可写 w=4 可读 r=2  可执行 x=1 )
第七步:重启samba服务
》systemctl restart smb

测试及使用:
win7:\10.xx.xx.xx\lcd   提示输入账号密码。
————————————————
版权声明:本文为CSDN博主「sparrowwf」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sparrowwf/article/details/81064318


先挂载好CentOS光盘文件

[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 即可网络驱动器映射jitai1目录。
win10的记事本,输入如下,保存为startupZ.bat文件
net use Z: \10.24.11.93\jitai1 jitai1 /user:jitai1 /persistent:yes

1.首先在电脑的左下角,点击开始菜单,在菜单中选择“运行”选项。
2.然后在运行窗口中输入“shell:startup”,点击确定。
3.此时打开的文件夹窗口就是“windows10启动”界面。
4.将startupZ.bat 放入该目录,开机自动映射网络驱动器。

A服务器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服务器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

定时拷贝就不用密码验证了。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

当前标题:CentOS7samba及windows映射网络驱动器,-创新互联
转载注明:https://www.cdcxhl.com/article20/dpddjo.html

成都网站建设公司_创新互联,为您提供响应式网站网站导航软件开发云服务器网站策划网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

微信小程序开发