Ubuntu – Mount a samba share as regular user using cifs

cifssambaUbuntu

Server: Ubuntu SAMBA 3
Client: Ubuntu 12.04

I can access the shares using Nautilus but I can't mount the same share using shell.

I issue the following command:

sudo mount -t cifs //auth.local/Aplicacao /home/josir/fontes -o rw,credentials=/home/josir/.smbcredentials,iocharset=utf8,codepage=unicode,uid=1000,gid=1000

The share is mounted but I could not see any subdirectory. I tried to find out why issuing:

josir@MEDIA35:$ ls -ls | grep fontes
0 drw-rws--- 13 josir josir      0 Out  4  2011 fontes

josir@MEDIA35:$ ls -ls fontes
ls: impossível acessar fontes/Software: Permissão negada
ls: impossível acessar fontes/Doc: Permissão negada
ls: impossível acessar fontes/Scripts: Permissão negada
ls: impossível acessar fontes/HmlFontes: Permissão negada

What am I missing ?

What's the correct mount command to get access to this samba share?

Do I have to use the same uid/gid of the samba user ?

Best Answer

1) Create a directory for your mount

mkdir ~/share

2) Create a group with the same gid of your "Domain Users" group defined on your Samba Server:

sudo groupadd domain_users -g 1901
sudo addgroup josir domain_users

3) Mount using mount.cifs utility:

sudo mount.cifs //server/sharepoint ~/share -o user=josir dom=mediasys 

Notes:

  • To see if it works, you should logout and login (due to the addgroup command)
  • To install mount.cifs: sudo apt-get install cifs-utils
  • If you could not access the ~/share directory, pass (2) didn't work well...
  • To know the gid Domain User, issue item (3) and then:

    ls -lsn | grep share