Mount samba with current user

When you want to mount a samba to modify the file , there are always some issues :

  • all kind of file permission issues
  • how to auto mount samba
  • Samba server setting

file permission

gid=1000,uid=1000,you can use id command to find your current user info

1
2
3
4
$ id
uid=1000(user) gid=1000(user) groups=1000(user),4(adm),
24(cdrom),27(sudo),30(dip),46(plugdev),112(lpadmin),128(sambashare)

how to auto mount samba

here is my /etc/fstab

1
2
//dbs-04/data /nfs/data/ cifs credentials=/home/.smbcredentials,uid=1000,gid=1000 0 0
//dbs-04/home /nfs/home/ cifs credentials=/home/.smbcredentials,uid=1000,gid=1000 0 0

the client user info is in /home/user/.smbcredentials,

1
2
3
4
$ cat /home/user/.smbcredentials
username=smbuser
password=smbuserpasswd

my server setting

1
2
3
4
5
6
7
[data]
comment = user
path = /data/user
browseable = yes
writeable = yes
guest ok = yes
force user = jbright

remember add your samba user into your server