CentOS7 samba 及windows映射网络驱动器,
admin
2023-01-24 13:22:38
0

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

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

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

相关内容

热门资讯

【第一资讯】“新卡农炸金花.是... 【第一资讯】“新卡农炸金花.是不是有挂?”果然有透视挂您好,新卡农炸金花这个游戏其实有挂的,确实是有...
终于懂了“响水麻将.真的有挂吗... 网上科普关于“响水麻将有没有挂”话题很是火热,小编也是针对响水麻将作*弊开挂的方法以及开挂对应的知识...
【第一资讯】“大富豪app.是... 有 亲,根据资深记者爆料大富豪app是可以开挂的,确实有挂(咨询软件无需...
【第一资讯】“拱趴大菠萝.辅助... 有 亲,根据资深记者爆料拱趴大菠萝是可以开挂的,确实有挂(咨询软件无需打...
中环云鑫数字赋能,重塑线上体验 在数字化浪潮席卷的今天,线上体验的深度与广度,已成为衡量一个平台乃至一个生态生命力的关键指标。然而,...
我来教教您“玄龙二厅.开挂器?... 家人们!今天小编来为大家解答玄龙二厅透视挂怎么安装这个问题咨询软件客服徽9752949的挂在哪里买很...
终于了解“至尊麻将.辅助开挂神... 家人们!今天小编来为大家解答至尊麻将透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...
终于明白“福星游戏.有挂吗?”... 有 亲,根据资深记者爆料福星游戏是可以开挂的,确实有挂(咨询软件无需打开...
今日重磅消息“全民牛牛.辅助器... 网上科普关于“全民牛牛有没有挂”话题很是火热,小编也是针对全民牛牛作*弊开挂的方法以及开挂对应的知识...
终于明白“来来灯塔.开挂神器?... 家人们!今天小编来为大家解答来来灯塔透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...