第一步:安装samba服务
》yum install samba
第二步:启动samba服务
》systemctl start smb
查看samba的状态
》systemctl status smb
看到Active就说明在运行中了
第三步:关闭防火墙
》systemctl stop firewalld.service //停止服务
》systemctl disable firewalld.service //关闭开机启动
同时还有这一步
设置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 = 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%d
date +%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
/2 * root /tmp/bakjitai1.sh
/3 * root /tmp/rmrfjitai1.sh
定时拷贝就不用密码验证了。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。