Linux 配置samba服务器

最近因为工作的需方便,需要在Linux上建立一个共享目录,供局域网内其他人访问!所以就要配置一个samba服务器!

经过多处查找资料和摸索,终于配置成功!

 

首先用root切换到samba目录下

 

root@huanghua-MS-7623:/etc/samba#

 

打开smb.conf文件,然后根据自己的需要做修改!我的配置如下:

 

[global]
    security = user
    encrypt passwords = yes

[myshare]
    comment = themes
    path = /home/huanghua/projects
    public = yes
    writable = yes
    read only = no
    force user = huanghua

 

[global]为全局属性。

[myshare]为自定义的共享 

 comment = themes 是描述,可有可无。

 path 当然为路径了

 public = yes 设置是否可发布

 writable = yes 设置为可写

 read only = no 是否只读

 force user = huanghua  以指定用户登陆

 

这样配置之后用smb://192.168.1.123 (windows下用 \\192.168.1.123  在运行里面打开)  便可以huanghua这个用户打开指定的目录,而且对目录可做任何操作,而且不用登陆,可以直接通过IP打开目录!

 

这样一个简单的samba服务器就配置好了,当然还有很多配置我都还不知道,比如如何弹出一个对话框用密码登陆,以及对指定的IP地址才能访问。那位高手会的可以留言告诉我,在下非常感谢!

 

 

下面是配置指定用户

 

 1.找到[homes]项,此项默认是注释掉的,取消其注释,然后修改其具体内容,修改成如下:

[homes]
   comment = Home Directories
   browseable = yes
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = no
# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
   create mask = 0755 #建议将权限修改成0755,这样其它用户只是不能修改
# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0755
# By default, \\server\username shares can be connected to by anyone
# with access to the samba server. Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
# The following parameter makes sure that only "username" can connect
#
# This might need tweaking when using external authentication schemes
   valid users = %S #本行需要取消注释

 2. 重启samba服务:

sudo service restart smbd

 

sudo service restart nmbd

 

3. 增加一个现有用户的对应samba帐号:

 

如我已经有一个用户叫reddy,现在给reddy开通samba帐号:

 

sudo smbpasswd -a reddy

 

根据提示输入两次密码即可。

 

4.现在可以测试了,在Window下输入samba地址尝试登录:

 

\\10.0.0.2\reddy

 

5.此时windows应该会弹出窗口要求输入用户名和密码了,输入吧。Enjoy!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值