Difference between revisions of "Configure SMB"

From Organic Design wiki
(SFTP: 4 installs required for Dokan)
({{legacy}})
 
(38 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{legacy}}
 
{{procedure
 
{{procedure
|description = '''(Incomplete)''' This procedure defines the steps required to set up a shared file directory over the Internet. The share should require authentication and be carried out over a secure connection.
+
|description = The most convenient way for a user to managing their online files is through the standard filing system interface in their local desktop environment, i.e. as a normal file share. Because it's available via the Internet, it needs to be a secure solution. We have two methods of setting up this kind of secure access to users files which are described in this procedure.
 
|role = sysop
 
|role = sysop
 +
|status = in use
 
}}__NOTOC__
 
}}__NOTOC__
  
After doing some research, it seems that the most popular and reliable way of achieving an internet-based file share is using [[w:Samba (software)|Samba]] over a [[w:VPN|Virtual Private Network (VPN)]]. [[w:WebDav|WebDav]] have turned out to be unreliable and temperamental.
+
Here's an example of our samba configuration format for the '''/etc/samba/smb.conf''' file:
 +
<source>
 +
[global]
 +
workgroup = Foo
 +
server string = Foo server
 +
wins support = yes
  
== SFTP ==
+
security = user
Another excellent option is [[w:SFTP|SFTP]] which uses existing [[w:SSH|SSH]] authentication to transfer files and there are applications available for Windows which map this connectivity in to the file system like a normal file share. On Ubuntu, SFTP integration with the file system is a standard feature, simply go in to ''Places/Connect to server'', select ''SSH'', fill in the authentication details and the resource will be mounted as usual.
+
encrypt passwords = yes
 +
password level = 3
 +
passdb backend = tdbsam
  
Unfortunately, the Windows client setup isn't quite as simple as the Ubuntu case, but there is a good application for integrating SFTP in to the FS called [http://dokan-dev.net Dokan]. There are a few other components to install onto the Windows machine before it's ready to map SSH drives as follows:
+
invalid users = root daemon bin sys mail sshd bind www-data
*Install the Microsoft .Net framework starting [http://www.microsoft.com/downloads/details.aspx?familyid=333325FD-AE52-4E35-B531-508D977D32A6&displaylang=en here] (63MB)
+
browseable = yes
*Install the [http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&displaylang=en
+
writable = yes
Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)]
+
create mask = 0777
*Download and install the main ''Dokan'' library from the [http://dokan-dev.net/download Dokan downloads page]
+
directory mask = 0777
*Finally download and install Dokan's SSH support (''Dokan SSHFS'') also from the [http://dokan-dev.net/download Dokan downloads page]
 
  
== OpenVPN ==
+
[staff]
OpenVPN is a full-featured SSL VPN solution which can accomodate a wide range of configurations, including remote access, site-to-site VPNs, WiFi security, and enterprise-scale remote access solutions with load balancing, failover, and fine-grained access-controls. OpenVPN is a single program that is run on both the server hosting the share, and on the clients which will be accessing it.
+
path = /shared/staff
 +
comment = Our staff files
 +
valid users = henry alan tabatha
 +
</source>
 +
*'''password level = 3''' means account ''foo'', ''Foo'' and ''FOO'' are all equivalent user names
 +
*'''log level = 4''' can be used to debug authentication and other problems, also directing at a single log file can help (instead of one per user)
 +
*'''passdb backend = tdbsam''' means use the basic password backend instead of the older ''smbpasswd'' format or scalable ''ldapsam''
 +
*'''Note:''' whatever password backend is used, ''smbpasswd'' needs to be run for each user before they can begin accessing shares
  
=== Server configuration ===
+
== Account synchronisation ==
First install OpenVPN with '''apt-get install openvpn''', and set up the TUN/TAP device using the following shell commands from root (this step is specific to our VPS host which doesn't have these devices created by default, see the [http://forums.vpslink.com/linux/116-dev-net-tun-tun-tap-bridge-disabled-please-enable-it.html issue raised in their forum] and the [http://wiki.vpslink.com/index.php?title=TUN/TAP_device_with_OpenVPN_or_Hamachi solution added to their wiki]):
+
The main issue with the initial configuration of Samba on the LAN server concerns the users and groups. What is the origin of the user/group information? and how does samba synchronise to it or use it to authenticate? Since all our servers run a wiki we decided to make the wiki the source of the users, passwords and groups information. To do this we instruct the local wiki daemon to set the unix and samba passwords whenever one is changed in the wiki. All this requires is to install the [[Extension:EventPipe|EventPipe extension]] on the server's administration wiki and ensure that it has a [[wikid.pl|wiki daemon]] configured and running.
<pre>
+
*Later we need to only synchronise accounts that are in a particular wiki group
mkdir -p /dev/net
+
*Later we should also allow the shares to be created and configured through FS records
mknod /dev/net/tun c 10 200
 
chmod 600 /dev/net/tun
 
</pre>
 
  
We'll go for a configuration which is as close to the default config file as possible to simplify the setup procedure. That means ''routed'' rather than ''bridged''.
+
== Next steps ==
 
+
*You may want to [[configure VPN]] remote access to the smb shares
=== Creating Keys ===
 
There's a utility called ''easy-rsa'' in ''/usr/share/doc/openvpn/examples/easy-rsa'' which should be copied to another location (we use ''/etc/openvpn/easy-rsa''. The default values for all certificates generated can be updated in the ''vars'' file. First, configure ''easy-rsa'' with the following shell commands:
 
<pre>
 
cp -pR /usr/share/doc/openvpn/examples/easy-rsa /etc
 
cd /etc/easy-rsa
 
mkdir keys
 
. ./vars
 
./clean-all
 
</pre>
 
 
 
Next we'll user ''easy-rsa'' to generate a master key, a server key and a couple of client keys (it's more secure for the client keys to be created locally, but we'll get that procedure sorted out another day!). Each of the commands requires a number of questions to be answered which can all be left as their defaults (which were set up in the ''vars'' file above), except for the ''common name'' setting which we'll set to "organicdesign-ca" for the master key, "server" for the server key, and the client name for all the client keys (e.g. "nad-laptop" or "zenia-office" for this example).
 
<pre>
 
./build-ca
 
./build-key-server server
 
./build-key nad-laptop
 
./build-key zenia-office
 
</pre>
 
Then after all the keys are made we must build the [[w:Diffie-Hellman key exchange|Diffie Hellman key exchange parameters]].
 
./build-dh
 
All the generated key files are in the ''easy-rsa/keys''. All the files having the ''.key'' suffix are secret and should only be communicated over encrypted connections like ''SCP''. The ''ca.crt'' file belongs on the server and all the client machines as well. The files that start with a client name belong on that client machine.
 
 
 
=== Setting up Ubuntu workstations ===
 
First install OpenVPN and the configuration GUI using '''apt-get install openvpn network-manager-openvpn'''. The GUI adds a "VPN Connections" item to the network menu from the system tray which VPN's can be added, removed and configured from.
 
 
 
=== Setting up on Windows workstations ===
 
On Windows OpenVPN is normally run from the console, which can be a little annoying to have lying on the taskbar all the time. OpenVPN GUI lets you run OpenVPN without this console window. Instead you get an icon in the notification area (the area on the right side of the taskbar) from which you can control OpenVPN to start/stop your VPN tunnels, view the log, change your password and other useful things.
 
 
 
The simplest setup (and the only one covered here) is if your internet connection is through a normal LAN or Wifi adapter and uses DHCP (i.e. "obtain IP address automatically" is ticked).
 
 
 
After OpenVPN has been installed, you'll notice in network settings that an extra LAN connection has been added. First, right-click it and rename it to "OpenVPN". Then select both the original network connection that you connect to the internet through, and the OpenVPN connection, then right-click and select "Bridge connections" which takes a few seconds to complete. After that's done a new icon will appear in the network list called "Network bridge" or something which you can rename to "OpenVPN Bridge". No more settings are required if your original internet connection used DHCP.
 
 
 
*See [http://openvpn.se OpenVPN GUI for Windows]
 
*[http://www.pavelec.net/adam/openvpn/bridge OpenVPN Bridging with Windows HOWTO]
 
  
 
== See also ==
 
== See also ==
*[http://wiki.openvz.org/VPN VPN on OpenVZ] (our VPS OS)
+
*[http://mercury.chem.pitt.edu/~sasha/LinuxFocus/English/March2002/article177.shtml Configuration tutorial]
 +
*[http://oreilly.com/catalog/samba/chapter/book/ch06_02.html Controlling access to shares]
 +
*[http://oreilly.com/catalog/samba/chapter/book/ch06_03.html Authentication security]
 +
*[http://oreilly.com/catalog/samba/chapter/book/ch06_04.html Passwords]

Latest revision as of 21:25, 3 June 2018

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.
Procedure.svg Configure SMB
Organic Design procedure

Here's an example of our samba configuration format for the /etc/samba/smb.conf file:

[global]
	workgroup = Foo
	server string = Foo server
	wins support = yes

	security = user
	encrypt passwords = yes
	password level = 3
	passdb backend = tdbsam

	invalid users = root daemon bin sys mail sshd bind www-data
	browseable = yes
	writable = yes
	create mask = 0777
	directory mask = 0777

[staff]
	path = /shared/staff
	comment = Our staff files
	valid users = henry alan tabatha
  • password level = 3 means account foo, Foo and FOO are all equivalent user names
  • log level = 4 can be used to debug authentication and other problems, also directing at a single log file can help (instead of one per user)
  • passdb backend = tdbsam means use the basic password backend instead of the older smbpasswd format or scalable ldapsam
  • Note: whatever password backend is used, smbpasswd needs to be run for each user before they can begin accessing shares

Account synchronisation

The main issue with the initial configuration of Samba on the LAN server concerns the users and groups. What is the origin of the user/group information? and how does samba synchronise to it or use it to authenticate? Since all our servers run a wiki we decided to make the wiki the source of the users, passwords and groups information. To do this we instruct the local wiki daemon to set the unix and samba passwords whenever one is changed in the wiki. All this requires is to install the EventPipe extension on the server's administration wiki and ensure that it has a wiki daemon configured and running.

  • Later we need to only synchronise accounts that are in a particular wiki group
  • Later we should also allow the shares to be created and configured through FS records

Next steps

See also