# Mounting Samba Shares is Wacky

## Ian

I use samba to connect between two linux computers, as well as the Windows computers on my network.

I have in my fstab a line that makes it mount, and set all files to be owned by my user, not root.

Recently, the fstab mount stopped working, and giving me this...

ratbert root # mount /mnt/ian

4698: session setup failed: ERRDOS - ERRnoaccess (Access denied.)

SMB connection failed

I figured something had changed in samba, let it tkae a day for the other side to be fixed, except it didn't fix itself.

Now, I use this line:

mount -t smbfs -o username=ian,password=<i aint putting no passwords on this forum  :Wink: >,gid=users,uid=ian //catbert/arch-ian /mnt/ian

It works great, except instead of setting all files to be owned by "ian", it sets them to be owned by "distcc".  That makes no sense to me, and it's rather annoying because I can't copy files over, but at least I can read them now.

So, does anyone know of any other way to set samba files to a certain username, or if I should just set up NFS (not sure how long that takes) instead?  If NFS is better, can someone give me a quick link to a good tutorial?

----------

## funkmankey

no problems with it here...

server smb.conf:

```
[distfiles]

   path = /usr/portage/distfiles

   public = no

   browseable = no

   valid users = portage

   guest ok = no

   writable = yes

   create mask = 0660

   force create mode = 0660

   force security mode = 0660

   directory mask = 0770

   force directory mode = 0770

   force directory security mode = 0770

   inherit permissions = Yes

   comment = /usr/portage/distfiles
```

client fstab:

```
//server/distfiles /usr/portage/distfiles smbfs defaults,credentials=/etc/samba/private/portage,uid=portage,gid=portage,dmask=770,fmask=660 0 0
```

```
%ls -ald /usr/portage/distfiles

drwxrwx---    1 portage  portage      4096 Oct 17 13:51 /usr/portage/distfiles/
```

----------

## neuron

I have the exact same problem, it was fine with 3.x on my desktop box, mounting shares from 2.2.8, but when I updated my server to 3.x my desktop box started doing that.

windows computers can mount just fine, I think you can use ldap and sync the username's instead of the uid's or something, though I haven't really looked into that.

----------

## Ian

I actually just set up NFS yesterday, because it's a lot easier for Linux --> Linux networking.  Samba is still there, but it's for Windows computers, so I don't have to deal with that anymore  :Smile: .

Interestingly enough though, NFS is still giving me the same error, I have to check some stuff out though, I saw a suggestion today in this forum, going to go check that now.

----------

## paulisdead

Ian, I've got the same exact problem, https://forums.gentoo.org/viewtopic.php?t=102366

It seems to be, for me at least, a problem only on the client's end with samba 3.0.  Last night I spent 3 hours messing with my server thinking that was the problem, but I downgraded samba to 2.2.8 on my desktop, and left the server as 3.0, and I can connect.  I tried running smbpasswd -a for the user's on both boxes, but no go with 3.0 on the client.  Also the Windows XP boxes on the LAN have no problems connecting to the Samba 3.0 server.

I've got my Linux+ certification class tonight, and my teacher does a Samba class as well, so I'm hoping he'll know how to fix this.

----------

## Ian

I seem to be having the same problem in NFS, so please ask about that too  :Razz: .

----------

## paulisdead

Well my teacher still hasn't upgraded any of his boxes to Samba 3.0, so he couldn't really help.  He said it's more than likely a bug in the samba client, since with the same options I can connect with the 2.2.8 client.  So I guess for now, the quick fix is to downgrade clients back to 2.2.8.

As for NFS, I don't know too much about, but do ya have the IP of the machine you want to mount the nfs share, in the servers /etc/exports?

----------

## Ian

NFS is connecting great, it's just the same issue as Samba, it's not letting me set files to a user/group.  It just kind of goes "I choose you, distcc, to be the owner of these shares!"  I'd love to know how/why it does that, and how I can change that behavior.

----------

## neuron

 *Ian wrote:*   

> NFS is connecting great, it's just the same issue as Samba, it's not letting me set files to a user/group.  It just kind of goes "I choose you, distcc, to be the owner of these shares!"  I'd love to know how/why it does that, and how I can change that behavior.

 

well, it does it because it's using the same uid's as your server.  The problem I'm having with samba is it didn't used to, and if you compile with -acl, it shouldn't.

----------

## Xiderpunk

The easiest fix to your problem is to set the same UID for your user on both boxes. The sado-masochistic fix (although the true nerd fix) would be to create a single sign on enviroment using LDAP + NIS + Samba, however, if you go this route be prepared to lose hair in frustration.

LDAP is sadly a horrendous system to set up (due to using an antiquated and extremely bloated set of standards, in X.500).

Hopefully in the not too distant future a real lightweight directory service will be available instead.

So my advice is go with manually setting UID's to the same on the boxes in question.

----------

## Ian

So would that be going into /etc/passwd, and going to "ian" and changing the "1000:100" part to the same thing on both computers?

Is it safe to change UID when the user is logged in?

Lastly, is it better to change, say the server to match the client (or the other way), or to change both to a new number (like 2000:200)?

----------

## Xiderpunk

I would think it would be better to change the UID on the server side to match the client, luckily.. Linux is very good at managing changes to users and groups. Also don't change the UID while the user is logged in.

Use the following command:

```

usermod -u [UID] [USER]

```

man usermod for more information on changing a UID.

HTH  :Smile: 

----------

