Search the Community
Showing results for tags 'samba'.
Found 2 results
I use Samba on a CentOS 6 server to share files between Windows, Linux and Mac clients. Guest access is allowed to all folders, but is read only, and there are several Samba accounts for writing files to the shares. The purpose of this tutorial is to document, roughly, what my configuration was to set up Samba for sharing a couple of folders on the local network in this way. Install Samba # yum install samba # service smb start # service nmb start # chkconfig nmb on # chkconfig smb on Create the sharing directories (In my actual setup, I have used /etc/fstab to mount these directories on separate, large disks, so there's plenty of space. That's beyond the scope of this tutorial, but: /etc/fstab UUID=xxxxxxxxx /var/lib/samba/photos ext3 defaults 1 0 UUID=xxxxxxxxx /var/lib/samba/sharedfiles ext3 defaults 1 0 with the real UUIDs substituted in!) Let's create the two directories where our shared files will be stored: # mkdir /var/lib/samba/photos # mkdir /var/lib/samba/sharedfiles Add the users and groups In order to support this model of guests having read only access, and granting write access only to known users, we need to have some users and groups set up at the Unix level. The users and groups at the Unix level map to some of the Samba users we will create later. They are separate users -- having a Samba login and password doesn't mean you have to give the user in question shell access, because they are two separate accounts and can have two separate passwords. We simply use the users, as I said, to 'map' the Samba credentials to the Unix permissions on disk. We will also create a group, samba-writers, to allow us to have group write access to the shared folders. I'll add my user account, peter, to this group. # groupadd samba-writers # usermod -a -G samba-writers peter Let's set the permissions on our two shared folders for this group: # chown peter:samba-writers /var/lib/samba/photos # chown peter:samba-writers /var/lib/samba/sharedfiles # chmod 775 /var/lib/samba/photos # chmod 775 /var/lib/samba/sharedfiles Mode '775' on a directory allows the user (peter), the group (samba-writers) to write files, and others (guests) to just read. Now, let's add the mappings between Samba users and Unix users. Open /etc/samba/smbusers using your favourite text editor. I'll use vim throughout this guide. # vim /etc/samba/smbusers peter = peter user1 = user1 user2 = user2 The example accounts user1 and user2 will be for our other Samba-enabled accounts. Again, we will create Unix shell accounts for user1 and user2, but use different passwords for SMB and their Unix account, and not share the shell password with the users. They only need and want Samba access, so we won't let them log in to the shell. First, we'll set my password for Samba. A different password from my shell login password. # smbpasswd -a peter ('-a' to add the user for the first time. To change it later, just 'smbpasswd peter') And let's add the other users. # useradd -G samba-writers -s /sbin/nologin user1 # passwd user1 # smbpasswd -a user1 Notice we set the shell to /sbin/nologin. These users, as I've said several times already, we are not allowing shell access. # useradd -G samba-writers -s /sbin/nologin user2 # passwd user2 # smbpasswd -a user2 Set up the configuration files Now that our users are ready for Samba, we need to set up the Samba configuration to share the two folders we've created, and allow the right level of access to users, as well as to guests. # vim /etc/samba/smb.conf The default CentOS configuration file has quite a lot already in it. Look for the headings, and make these changes: Under Network Related Options: workgroup = WORKGROUP server string = Server Shared Files netbios name = MACHINENAME hosts allow = 127. 192.168.0. hosts deny = ALL Set WORKGROUP to the workgroup name, if it's configured differently on your Windows clients. (On some older Windows versions, it may need to be MSHOME.) Set MACHINENAME to the name you want the Samba server to have. Finally, we use the 'hosts allow' and 'hosts deny' directives to force Samba only to serve to clients on the local network. In this case, 192.168.0.1 -- 192.168.0.254. You may want to change this to your IP addressing scheme in your network, or remove it to not restrict access to the local network. Under Standalone Server Options: security = user passdb backend = tdbsam map to guest = Bad Password domain master = yes Under Browser Control Options: local master = yes os level = 99 preferred master = yes These directives aren't strictly necessary -- in fact, they may cause conflict if you're doing other Windows networking things on the same workgroup. 'os level = 99', combined with the other options, will force this machine to be the 'local master browser' (LMB) and the 'domain master browser' (DMB). Whichever machine on the network has these roles is responsible for keeping a list of the other machines on the network. Clients use this list to look for other machines that have shared folders available. I've found that forcing my Samba server to be the LMB and DMB, as well as using it as a WINS server, speeds up the time it takes Windows to 'search' for other machines on the network by many many times. (Remember opening 'My Network Places' and clicking 'Show workgroup computers' only to have to wait 15 seconds while Explorer locks up? This avoids that.) In more complex scenarios, you might not want to enable this to avoid conflict. For our small network scenario, it's a useful speed bonus and causes no problems. Under Name Resolution: wins support = yes Samba becomes a WINS server, which again can help speed things up -- it means you can address other sharing computers by name without waiting for long periods for NetBIOS to resolve the name. (Some more tech info about this, if you're interested.) You may want to configure your Windows machines' 'WINS server' IP address to point to your Samba server to get this benefit. (You might need to configure this in your router's DHCP settings for it to stick to all of them.) Finally, at the bottom of the file, we add our shares: [sharedfiles] comment = Shared files for the network path = /var/lib/samba/sharedstuff guest ok = yes writable = no create mask = 0664 directory mask = 0775 force group = samba-writers write list = @samba-writers [Photos] comment = Shared photos path = /var/lib/samba/photos guest ok = yes writable = no create mask = 0664 directory mask = 0775 force group = samba-writers write list = @samba-writers Each folder has its own name in brackets, followed by the options for that folder. We use 'guest ok = yes' to allow guests, but 'writable = no' to make them read only. Anyone in the 'write list' (anyone in the group samba-writers) can write. There are also other settings to set the default permisisons on files ('create mask = 0664', owner read+write, group read+write, others read only) and folders ('directory mask = 0775', owner read+write+enter, group read+write+enter, others read+enter). Once we're done, save that file and quit the editor, and reload Samba: # service smb restart # service nmb restart Just make sure your firewall is letting Samba through: # system-config-firewall-tui And we're ready to test! Accessing the shares Linux Without logging in, we can access the shares by going to smb://machinename (or smb://192.168.0.whatever) in the address bar of the file manager. This works in most file managers. To log in and have write access, you may have luck with a 'Connect to Server' window that lets you type in the username and password, like this one in the Ubuntu 12.04 desktop's File menu. I've had problems with write access this way, though, so you may need to use something like smbfs to mount the share permanently. Mac Under recent versions of Mac OS X, the server should appear right away in the Finder's sidebar. Simply click the server name to see the shares and browse them. For write access, simply click the 'Connect As' button in the window and enter your username and password for SMB that you set up earlier. If you don't see the server in the sidebar, (Lion is more temperamental than Snow Leopard was about this), press ⌘K to bring up the 'Connect to Server' dialogue. Type cifs://machinename or cifs://192.168.0.whatever and click OK to connect. Windows The server should show up in 'Network' for guest access. The best way to log in and have write access, I have found, is to map the shared folder as a network drive. In an Explorer window, click 'Map Network Drive' in the toolbar (it's under the Tools menu on Windows XP and earlier). Choose a drive letter, enter \\machinename\foldername as the path, and make sure you tick to 'Connect using different credentials'. You'll then be asked for the username and password, which is the SMB password you set for the account earlier.
Hello all. I am recently returning to Linux after about a 10 year absence. I have not kept up with development except through various articles. Here is my plight. I have searched and there are really no topics that actually fit what I am looking for. And google seems to bring me here time and time again. I dont want a dedicated NAS OS. I want to be able to do other things with the system on occasion, not continuous, i.e. development, etc. I am looking to set up a home NAS/media/file/backup server. I am not really asking for Distro advice as I am going to use CentOS. I am running it on Gigabyte GA-H61N-USB3 1155 ITX with Intel Pentium G630T (35W CPU) 8 GB DDR3 1333 Perc 5/i w/ 4 WD RE4 1TB Dirves. Here is what will be on the network. 1 MBP (heavy use) with OSX 10.7 maybe upgrade to 10.8 1 Windows 7 Laptop (wifes mostly for internet FB stuff) 1 Xeon Workstation with OSX/ WIndows7/ Fedora 15 1 iPad (internet and file sharing) 1 Kindle Fire (internet use only) 2 Android Phone (mostly using internet, no file sharing) 1 Sony BP-S580 DLNA capable Blu-Ray 1 Xbox 360 Mostly This will be for streaming files and media in the network but I am also returning to school to get another degree. (Programming this time versus current Admin Degree. ) So I will be accessing files remotely. The reason I am here is to find out what packages should I grab. I have a static IP with 2 firewalls but want to access files etc. I want as secure as possible so VPN is a good place to start. SFTP for letting a friend or iPad access media server for itunes files as well as other media. Samba of course. And anything else you can think of that will help. I tried this same question at 2 other sites and got the general consensus response WHS. I DONT want M$. I have it because I work with it and I am tired of it. Windows 7 is the last M$ OS I will run. Although OSX is my OS I use the most. But I am not a FANBOY either. Any ideas help or corrections please feel free. Even criticism is welcome, constructively for a 2nd time n00b.