Projekt

Allgemein

Profil

Setup samba » Historie » Version 1

Jeremias Keihsler, 13.01.2017 13:12

1 1 Jeremias Keihsler
h1. Install Procedure for samba
2
3
h2. Requirements
4
5
To install samba you will need the following:
6
* a installed and supported operating system (e.g. CentOS 6.x)
7
* root-access
8
* a fast internet connection
9
10
h2. Preliminary Note
11
12
this is based on http://jehurst.wordpress.com/2011/01/17/rhel-6-for-the-clueless-samba-server/
13
14
I’ve found a couple of tutorials on Samba, but neither one had all the right information. After fighting with it a bit, this is what I did to get it working.
15
16
h2. Install 
17
18
Install Samba by logging into a Terminal as root:
19
<pre><code class="bash">
20
yum install samba
21
</code></pre>
22
if you want to have access to samba-shares you also want to
23
<pre><code class="bash">
24
yum install samba-client
25
</code></pre>
26
27
h2. Setup 
28
29
30
h3. Setup SeLinux
31
32
If SeLinux is active, then it might be necessary to set some samba-related variables depending on the share-location.
33
34
This and more information can be found at http://selinuxproject.org/page/SambaRecipes
35
36
The @samba_export_all@ Flag will allow to share any folder on the machine, use with care.
37
<pre><code class="bash">
38
setsebool -P samba_export_all_rw=1
39
</code></pre>
40
41
<pre><code class="bash">
42
setsebool -P samba_enable_home_dirs=1
43
</code></pre>
44
45
h3. Setup a shared directory
46
47
Create shared directory; I used /home/shared:
48
49
<pre><code class="bash">
50
mkdir /home/shared
51
chmod a+w /home/shared
52
chcon -t samba_share_t /home/shared
53
</code></pre>
54
55
That last line insures the SELinux security system knows to allow outside systems to poke around in that folder. Now anyone using this computer can move files in and out of the folder, as well as the Samba users.
56
57
h3. Setup a samba user
58
59
Add a Samba user. This is a different task than simply adding a user account. There is a GUI tool for adding Linux user accounts to the machine for them to use the computer itself. However, Samba users must be handled differently, so that the system forces them to use the Samba server.
60
61
<pre><code class="bash">
62
useradd -c "Real Name" -d /home/samba-username -s /sbin/nologin samba-username
63
</code></pre>
64
65
That’s all one line. As usual, substitute the actual Real Name and samba-username in the command above. Then create the Samba password. Remember what we said about coming up with good passwords:
66
67
<pre><code class="bash">
68
smbpasswd -a samba-username
69
</code></pre>
70
71
It will prompt for the password, which you type in blindly:
72
73
<pre><code class="bash">
74
New SMB password:
75
Retype new SMB password:
76
Added user username.
77
</code></pre>
78
79
Edit smbusers:
80
<pre><code class="bash">
81
vim /etc/samba/smbusers
82
</code></pre>
83
84
This will open the default text editor. Scan down the file until you see something like this:
85
86
<pre><code class="bash">
87
root = administrator admin
88
nobody = guest pcguest smbguest
89
</code></pre>
90
91
Immediately below this, add a line with this format:
92
93
<pre><code class="bash">
94
username = samba-username
95
</code></pre>
96
97
so CentOS recognizes the person logging in from the Winbox by their samba-username.
98
99
h3. Setup a samba config
100
101
Then open: 
102
<pre><code class="bash">
103
vim /etc/samba/smb.conf
104
</code></pre>
105
Find the section headed '[global]'. Change the workgroup name to whatever your Windows computer will be seeking. Default is workgroup in lower case letters. You’ll need to remove the semicolon in front of the next line and provide a proper hostname for the netbios name, which would be the name you gave your RHEL computer during installation, again in lower case. Remove the semicolon from the next line and the IP address numbers from the sample; all we need are the two interfaces lo eth0. Below that is a line with hostsallow as a model. Below that, start a new line with the same indentation:
106
107
<pre><code class="bash">
108
hosts allow = 127. 192.168.1.
109
</code></pre>
110
111
The “127.” is the IP address for everything on your own machine. The other (192.168.1.) is the private LAN network I use for my home router; by leaving off the last section after the dot, it automatically includes every computer with that prefix, which is reserved for LANs.
112
113
If you want to bind to specific interfaces only you maybe want to consider
114
<pre><code class="bash">
115
interfaces = lo vboxnet0 192.168.56.1/24
116
bind interfaces only = yes
117
</code></pre>
118
119
Go all the way to the bottom of the file and add some lines. I named my shared directory “shared”. Thus, the section heading should be named the same:
120
121
<pre><code class="ini">
122
[shared]
123
path = /home/shared
124
writeable = yes
125
browseable = yes
126
read only = No
127
guest ok = Yes
128
public = Yes
129
valid users = username1 username2
130
create mask = 0666
131
directory mask = 0777
132
</code></pre>
133
134
h3. Setup the firewall
135
136
Now change the firewall to allow Samba to get through. You can use the tool in System > Administration > Firewall. Simply scan down the list to Samba and checkmark the box. Optionally checkmark IPP printer sharing. Then hit “Apply”.
137
<pre><code class="bash">
138
system-config-firewall
139
</code></pre>
140
or in Textmode
141
<pre><code class="bash">
142
system-config-firewall-tui
143
</code></pre>
144
145
h3. Setup the services
146
147
check the status of the services with
148
<pre><code class="bash">
149
chkconfig
150
</code></pre>
151
<pre><code class="bash">
152
chkconfig smb on
153
chkconfig nmb on
154
</code></pre>
155
156
h2. Test 
157
158
following commands might be helpful:
159
<pre><code class="bash">
160
findsmb
161
smbclient //host/share -U username
162
</code></pre>