I can connect to Samba server but cannot access shares.

I'm having trouble getting samba sharing working to access shares.

I have setup a stand-alone box running Fedora 16 to use as a file-sharing and web development server. It needs to be able to share files with a Windows 7 PC and a Mac running OSX Snow Leopard.

I've setup Samba using the Samba configuration GUI tool on Fedora. Added users to Fedora and connected them as Samba users (which are the same as the Windows and Mac usernames and passwords). The workgroup name is the same as the Windows workgroup. Authentication is set to User. I've allowed Samba and Samba client through the firewall and set the ethernet to a trusted port in the firewall.

Both the Windows and Mac machines can connect to the server and view the shares, however when trying to access the shares, Windows throws error:

0x80070035 " Windows cannot access \\SERVERNAME\ShareName." 

Windows user is not prompted for a username or password when accessing the server (found under "Network Places"). This also happens when connecting with the IP rather than the server name.

The Mac can also connect to the server and see the shares but when choosing a share gives the error:

The original item for ShareName cannot be found.

When connecting via IP, the Mac user is prompted for username and password, which when authenticated gives a list of shares, however when choosing a share to connect to, the error is displayed and the user cannot access the share.

Since both machines are acting similarly when trying to access the shares, I assume it is an issue with how Samba is configured.

smb.conf:

[global]

    workgroup = workgroup
    server string = Server
    log file = /var/log/samba/log.%m
    max log size = 50
    security = user
    load printers = yes
    cups options = raw
    printcap name = lpstat
    printing = cups


[homes]
    comment = Home Directories
    browseable = no
    writable = yes


[printers]
    comment = All Printers
    path = /var/spool/samba
    browseable = yes
    printable = yes

[FileServ]
    comment = FileShare
    path = /media/FileServ
    read only = no
    browseable = yes
    valid users = user1, user2

[webdev]
    comment = Web development
    path = /var/www/html/webdev
    read only = no
    browseable = yes
    valid users = user1

How do I get samba sharing working?

UPDATE: I Figured it out, it was because I was sharing a second hard drive. See checked answer below.

Speculation 1: Before this box I had another box with the same version of fedora installed (16) and samba working for these same computers. I started up the old machine and copied the smb.conf file from the old machine to the new one (editing the share definitions for the new shares of course) and I still get the same errors on both client machines. The only difference in environment is the hardware and the router. On the old machine the router received a dynamic public IP and assigned dynamic private IPs to each device on the network while the new machine is connected to a router that has a static public IP (still dynamic internal IPs though.) Could either one of these be affecting Samba?

Speculation 2: As the directory I am trying to share is actually an entire internal disk, I have tried these things:

1.) changing the owner of the mounted disk from root to my user (which is the same username as on the Windows machine)

2.) made a share that only included one of the folders on the disk instead of the entire disk with my user again as the owner.

Both tests failed giving me the same errors regarding the network address.

Speculation 3: Whenever I try to connect to the share on the Windows 7 client I am prompted for my username and password. When I enter the correct credentials I get an access denied message. However I did notice that under the login box "domain: WINDOWS-PC-NAME" is listed. I believe this could very well be the problem.

Speculation 4: So I've completely reinstalled Fedora and Samba now. I've created a share on the first harddrive (one fedora is installed on) and I can access that fine from Windows. However when I try to share any data on the second disk, I am receiving the same error. This I believe is the problem. I think I need to change some things in fstab or fdisk or something.

Speculation 5: So in fstab I mapped the drive to automount in a folder which works correctly. I also added the samba_share_t SElinux label to the mountpoint directory which now allows me to access the shares on the Windows machine, however I cannot see any of the files in the directory on the windows machine. (They are there, I can see them in the fedora file browser locally)


Solution 1:

Finally got it. So first off the problem was with the fact that I was trying to share a second harddrive, instead of data on the same drive that the os was installed on. Here are the steps to be able to share a second drive over Samba: (These are for an internally mounted drive, but I think it may also work for externals)

1.) You must setup the drive to automount in fstab. add:

/dev/sdbx /mountpoint ext3 auto 0 0

to /etc/fstab where x is the partition number for the drive, "/media/mountpoint" is the mount directory (I created a directory called /share and mounted the drive there) and "ext3" is the filesystem

2.) set the permission for the mount point to 755:

chmod 755 /mountpoint

3.) Add a new SElinux label "samba_share_t" and apply this label to the mountpoint

chcon -t samba_share_t /mountpoint

4.) Apply these permissions to all enclosed files and folders. (I used Gnome's GUI for this)

I can access read and write to the share from both a Windows 7 PC and a Mac running OSX.

Solution 2:

Post your smb.conf, so we can check if all your configuration is ok.

The most important part of your smb.conf is something like this:

[name_of_the_shared_folder_resource]
   valid users = user1 user2    #you can use groups
   public = no
   path = /var/www    #the path of your folder
   printable = no
   writable = yes

Remember run smbpasswd for each user to generate the Samba Password.

Another important thing... restart Samba. :P