如何配置samba来访问linux服务器?
首先,在服务器上安装samba
sudo apt-get install samba
此时打开配置文件/etc/samba/smb.conf
,将内容修改为如下形式
[global]
workgroup = WORKGROUP
passdb backend = tdbsam
printing = cups
printcap name = cups
printcap cache time = 750
cups options = raw
map to guest = Bad User
include = /etc/samba/dhcp.conf
logon path = \\%L\profiles\.msprofile
logon home = \\%L\%U\.9xprofile
logon drive = P:
usershare allow guests = Yes
add machine script = /usr/sbin/useradd -c Machine -d /var/lib/nobody -s /bin/false %m$
domain logons = Yes
domain master = Yes
local master = Yes
os level = 65
preferred master = Yes
security = user
wins support = No
usershare max shares = 10
ldap admin dn =
wins server =
follow symlinks = yes
wide links = yes
unix extensions = no
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[profiles]
comment = Network Profiles Service
path = %H
read only = No
store dos attributes = Yes
create mask = 0600
directory mask = 0700
[users]
comment = All users
path = /home
read only = No
inherit acls = Yes
veto files = /aquota.user/groups/shares/
[data1]
comment = disk data1
path = /data1
read only = No
#guest ok = Yes
#valid users = %S, %D%w%S
inherit acls = Yes
据此参数含义可以参见这篇文档.
配置好后,还需要以下几个步骤,才能在自己电脑上访问到服务器。
创建samba用户
useradd -a user1
这里的
user1
是帐号名,必须是已经在系统里存在的,才可以。添加
user1
为samba帐号pdbedit -a user1
此时会让你输入密码,如果输完密码提示failed,多半是因为权限问题,加一个sudo就好。
重启samba服务
service smb restart
重启好后,在自己的电脑上,点击Connect to Server,输入smb://192.168.10.5
,点击连接。如下图所示:
然后就进入了服务器的界面,第一次进入可能需要输入密码,选择永久记住即可,smb访问的好处是不用每次ssh来连接,传东西也稍微方便点。