~kim0/serverguide/serverguide-review-ch19

« back to all changes in this revision

Viewing changes to serverguide/C/remote-administration.xml

  • Committer: Matthew East
  • Date: 2011-05-03 07:11:18 UTC
  • Revision ID: mdke@ubuntu.com-20110503071118-081aatibsr9k2yqy
Add files from ubuntu-docs natty branch, trim to use only those necessary for serverguide

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
 
3
        "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
 
4
<!ENTITY % globalent SYSTEM "../../libs/global.ent">
 
5
%globalent;
 
6
<!ENTITY % gnome-menus-C SYSTEM "../../libs/gnome-menus-C.ent">
 
7
%gnome-menus-C;
 
8
<!ENTITY % xinclude SYSTEM "../../libs/xinclude.mod">
 
9
%xinclude;
 
10
<!ENTITY language "&EnglishAmerican;">
 
11
]>
 
12
<chapter id="remote-administration" status="review">
 
13
        <title>Remote Administration</title>
 
14
        <para>
 
15
        There are many ways to remotely administer a Linux server.  This chapter will cover
 
16
        one of the most popular <application>OpenSSH</application>.
 
17
        </para>
 
18
        <sect1 id="openssh-server" status="review">
 
19
                <title>OpenSSH Server</title>
 
20
      <sect2 id="openssh-introduction">
 
21
        <title>Introduction</title> 
 
22
           <para>
 
23
            This section of the Ubuntu &sg-title; introduces a powerful collection of tools
 
24
            for the remote control of networked computers and transfer of data between 
 
25
            networked computers, called <emphasis>OpenSSH</emphasis>. You will also learn
 
26
            about some of the configuration settings possible with the OpenSSH server 
 
27
            application and how to change them on your Ubuntu system. 
 
28
          </para>
 
29
          <para>
 
30
            OpenSSH is a freely available version of the Secure Shell (SSH) protocol family of 
 
31
            tools for remotely controlling a computer or transferring files between computers.
 
32
            Traditional tools used to accomplish these functions, such as 
 
33
            <application>telnet</application> or <application>rcp</application>, are insecure 
 
34
            and transmit the user's password in cleartext when used. OpenSSH provides a server 
 
35
            daemon and client tools to facilitate secure, encrypted remote control and file 
 
36
            transfer operations, effectively replacing the legacy tools.
 
37
          </para>
 
38
          <para>
 
39
            The OpenSSH server component, <application>sshd</application>, listens 
 
40
            continuously for client connections from any of the client tools. When a connection 
 
41
            request occurs, <application>sshd</application> sets up the correct connection 
 
42
            depending on the type of client tool connecting. For example, if the remote 
 
43
            computer is connecting with the <application>ssh</application> client application, 
 
44
            the OpenSSH server sets up a remote control session after authentication. If a 
 
45
            remote user connects to an OpenSSH server with <application>scp</application>, the 
 
46
            OpenSSH server daemon initiates a secure copy of files between the server and 
 
47
            client after authentication. OpenSSH can use many authentication methods, including             plain password, public key, and <application>Kerberos</application> tickets.
 
48
            </para>
 
49
          </sect2>
 
50
        <sect2 id="openssh-installation">
 
51
        <title>Installation</title>
 
52
        <para>
 
53
        Installation of the OpenSSH client and server applications is simple. To install the 
 
54
        OpenSSH client applications on your Ubuntu system, use this command at a terminal 
 
55
        prompt:
 
56
        </para>
 
57
<screen>
 
58
<command>sudo apt-get install openssh-client</command>
 
59
</screen>
 
60
        <para>
 
61
        To install the OpenSSH server application, and related support files, use this command 
 
62
        at a terminal prompt:
 
63
        </para>
 
64
<screen>
 
65
<command>sudo apt-get install openssh-server</command>
 
66
</screen>
 
67
        <para>
 
68
        The <application>openssh-server</application> package can also be selected to 
 
69
        install during the Server Edition installation process.
 
70
        </para>
 
71
        </sect2>
 
72
        <sect2 id="openssh-configuration">
 
73
          <title>Configuration</title>
 
74
          <para>
 
75
          You may configure the default behavior of the OpenSSH server application, 
 
76
          <application>sshd</application>, by editing the file 
 
77
          <filename>/etc/ssh/sshd_config</filename>. For information about the configuration 
 
78
          directives used in this file, you may view the appropriate manual page with the 
 
79
          following command, issued at a terminal prompt:
 
80
          </para>
 
81
<screen>
 
82
<command>man sshd_config</command>
 
83
</screen>
 
84
            <para>
 
85
            There are many directives in the <application>sshd</application> configuration 
 
86
            file controlling such things as communication settings and authentication modes. 
 
87
            The following are examples of configuration directives that can be changed by 
 
88
            editing the <filename>/etc/ssh/sshd_config</filename> file.
 
89
            </para>
 
90
            <tip>
 
91
                <para>Prior to editing the configuration file, you should make a copy of the 
 
92
                original file and protect it from writing so you will have the original 
 
93
                settings as a reference and to reuse as necessary.
 
94
                </para>
 
95
                <para>Copy the <filename>/etc/ssh/sshd_config</filename> file and protect it 
 
96
                from writing with the following commands, issued at a terminal prompt:
 
97
                </para>
 
98
            </tip>
 
99
<screen>
 
100
<command>sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original</command>
 
101
<command>sudo chmod a-w /etc/ssh/sshd_config.original</command>
 
102
</screen>
 
103
            <para>
 
104
            The following are examples of configuration directives you may change:
 
105
            </para>
 
106
           <itemizedlist>
 
107
               <listitem>
 
108
               <para>
 
109
               To set your OpenSSH to listen on TCP port 2222 instead of the default TCP port 
 
110
               22, change the Port directive as such:
 
111
               </para>
 
112
               <para>
 
113
               Port 2222
 
114
               </para>
 
115
               </listitem>
 
116
        <listitem>
 
117
            <para>
 
118
            To have <application>sshd</application> allow public key-based login credentials, 
 
119
            simply add or modify the line:
 
120
            </para>
 
121
               <para>
 
122
               PubkeyAuthentication yes
 
123
               </para>
 
124
            <para>
 
125
            In the <filename>/etc/ssh/sshd_config</filename> file, or if already present, 
 
126
            ensure the line is not commented out.
 
127
            </para>
 
128
            </listitem>
 
129
            <listitem>
 
130
             <para>
 
131
             To make your OpenSSH server display the contents of the 
 
132
             <filename>/etc/issue.net</filename> file as a pre-login
 
133
             banner, simply add or modify the line:
 
134
             </para>
 
135
               <para>
 
136
               Banner  /etc/issue.net
 
137
               </para>
 
138
               <para>
 
139
               In the <filename>/etc/ssh/sshd_config</filename> file.
 
140
               </para>
 
141
             </listitem>
 
142
             </itemizedlist>
 
143
            <para>
 
144
            After making changes to the <filename>/etc/ssh/sshd_config</filename> file, save 
 
145
            the file, and restart the <application>sshd</application> server application to 
 
146
            effect the changes using the following command at a terminal prompt:
 
147
            </para>
 
148
<screen>
 
149
<command>sudo /etc/init.d/ssh restart</command>
 
150
</screen>
 
151
                <warning>
 
152
                  <para>
 
153
                  Many other configuration directives for <application>sshd</application> are 
 
154
                  available for changing the server application's behavior to fit your needs. 
 
155
                  Be advised, however, if your only method of access to a server is 
 
156
                  <application>ssh</application>, and you make a mistake in configuring 
 
157
                  <application>sshd</application> via the 
 
158
                  <filename>/etc/ssh/sshd_config</filename> file, you may find you
 
159
                  are locked out of the server upon restarting it, or that the 
 
160
                  <application>sshd</application> server refuses to start due to an incorrect 
 
161
                  configuration directive, so be extra careful when editing this file on a 
 
162
                  remote server.
 
163
                  </para>
 
164
                </warning>
 
165
        </sect2>
 
166
   <sect2 id="openssh-keys" status="review">
 
167
     <title>SSH Keys</title>
 
168
     <para>
 
169
     SSH <emphasis>keys</emphasis> allow authentication between two hosts without the need of a password.  SSH key authentication 
 
170
     uses two keys a <emphasis>private</emphasis> key and a <emphasis>public</emphasis> key.
 
171
     </para>
 
172
     <para>
 
173
     To generate the keys, from a terminal prompt enter:
 
174
     </para>
 
175
<screen>
 
176
<command>ssh-keygen -t dsa</command>
 
177
</screen>
 
178
     <para>
 
179
     This will generate the keys using a <emphasis>DSA</emphasis> authentication identity of the user.  During the process you
 
180
     will be prompted for a password.  Simply hit <emphasis>Enter</emphasis> when prompted to create the key.  
 
181
     </para>
 
182
     <para>
 
183
     By default the <emphasis>public</emphasis> key is saved in the file <filename>~/.ssh/id_dsa.pub</filename>, while 
 
184
     <filename>~/.ssh/id_dsa</filename> is the <emphasis>private</emphasis> key.  Now copy the <filename>id_dsa.pub</filename> file
 
185
     to the remote host and append it to <filename>~/.ssh/authorized_keys</filename> by entering:
 
186
     </para>
 
187
<screen>
 
188
<command>ssh-copy-id username@remotehost</command>
 
189
</screen>
 
190
     <para>
 
191
     Finally, double check the permissions on the <filename>authorized_keys</filename> file, only the authenticated user should have read and write permissions.
 
192
     If the permissions are not correct change them by:
 
193
     </para>
 
194
<screen>
 
195
<command>chmod 600 .ssh/authorized_keys</command>
 
196
</screen>
 
197
     <para>
 
198
     You should now be able to SSH to the host without being prompted for a password.
 
199
     </para>
 
200
   </sect2>
 
201
   <sect2 id="openssh-references" status="review">
 
202
      <title>References</title>
 
203
 
 
204
      <itemizedlist>
 
205
        <listitem>
 
206
          <para>
 
207
          <ulink url="https://help.ubuntu.com/community/SSH">Ubuntu Wiki SSH</ulink> page.
 
208
          </para>
 
209
        </listitem>
 
210
        <listitem>
 
211
          <para>
 
212
          <ulink url="http://www.openssh.org/">OpenSSH Website</ulink>
 
213
          </para>
 
214
        </listitem>
 
215
        <listitem>
 
216
          <para>
 
217
          <ulink url="https://wiki.ubuntu.com/AdvancedOpenSSH">Advanced OpenSSH Wiki Page</ulink>
 
218
          </para>
 
219
        </listitem>
 
220
      </itemizedlist>
 
221
 
 
222
   </sect2>
 
223
  </sect1>
 
224
  <sect1 id="puppet" status="review">
 
225
    <title>Puppet</title>
 
226
 
 
227
      <para>
 
228
      <application>Puppet</application> is a cross platform framework enabling system administrators to perform common tasks using code.  
 
229
      The code can do a variety of tasks from installing new software, to checking file permissions, or updating user accounts.  Puppet is 
 
230
      great not only during the initial installation of a system, but also throughout the system's entire life cycle.  In most circumstances
 
231
      <application>puppet</application> will be used in a client/server configuration.  
 
232
      </para>
 
233
 
 
234
      <para>
 
235
      This section will cover installing and configuring <application>puppet</application> in a client/server configuration.  This simple example
 
236
      will demonstrate how to install <application>Apache</application> using <application>Puppet</application>.
 
237
      </para>
 
238
 
 
239
    <sect2 id="puppet-installation" status="review">
 
240
      <title>Installation</title>
 
241
 
 
242
      <para>
 
243
      To install <application>puppet</application>, in a terminal on the <emphasis>server</emphasis> enter:
 
244
      </para>
 
245
 
 
246
<screen>
 
247
<command>sudo apt-get install puppetmaster</command>
 
248
</screen>
 
249
 
 
250
      <para>
 
251
      On the <emphasis>client</emphasis> machine, or machines, enter:
 
252
      </para>
 
253
 
 
254
<screen>
 
255
<command>sudo apt-get install puppet</command>
 
256
</screen>
 
257
 
 
258
    </sect2>
 
259
    <sect2 id="puppet-configuration" status="review">
 
260
      <title>Configuration</title>
 
261
 
 
262
      <para>
 
263
      Prior to configuring <application>puppet</application> you may want to add a DNS <emphasis>CNAME</emphasis> record for 
 
264
      <emphasis>puppet.example.com</emphasis>, where <emphasis>example.com</emphasis> is your domain.  By default 
 
265
      <application>puppet</application> clients check DNS for puppet.example.com as the puppet server name, or 
 
266
      <emphasis>Puppet Master</emphasis>.  See <xref linkend="dns"/> for more DNS details.
 
267
      </para>
 
268
 
 
269
      <para>
 
270
      If you do not wish to use DNS, you can add entries to the server and client <filename>/etc/hosts</filename> file.  For example, in the 
 
271
      <application>puppet</application> server's <filename>/etc/hosts</filename> file add:
 
272
      </para>
 
273
 
 
274
<programlisting>
 
275
127.0.0.1 localhost.localdomain localhost puppet
 
276
192.168.1.17 meercat02.example.com meercat02
 
277
</programlisting>
 
278
 
 
279
      <para>
 
280
      On each <application>puppet</application> client, add an entry for the server:
 
281
      </para>
 
282
 
 
283
<programlisting>
 
284
192.168.1.16 meercat.example.com meercat puppet
 
285
</programlisting>
 
286
 
 
287
      <note>
 
288
        <para>
 
289
        Replace the example IP addresses and domain names above with your actual server and client addresses and domain names.
 
290
        </para>
 
291
      </note>
 
292
 
 
293
      <para>
 
294
      Now setup some resources for <application>apache2</application>.  Create a file <filename>/etc/puppet/manifests/site.pp</filename>
 
295
      containing the following:
 
296
      </para>
 
297
 
 
298
<programlisting>
 
299
package {
 
300
    'apache2':
 
301
        ensure => installed
 
302
}
 
303
 
 
304
service {
 
305
    'apache2':
 
306
        ensure => true,
 
307
        enable => true,
 
308
        require => Package['apache2']
 
309
}
 
310
</programlisting>
 
311
 
 
312
 
 
313
      <para>
 
314
      Next, create a node file <filename>/etc/puppet/manifests/nodes.pp</filename> with:
 
315
      </para>
 
316
 
 
317
<programlisting>
 
318
node 'meercat02.example.com' {
 
319
   include apache2
 
320
}
 
321
</programlisting>
 
322
 
 
323
      <note>
 
324
        <para>
 
325
        Replace <emphasis>meercat02.example.com</emphasis> with your actual puppet client's host name.
 
326
        </para>
 
327
      </note>
 
328
 
 
329
      <para>
 
330
      The final step for this simple <application>puppet</application> server is to restart the daemon:
 
331
      </para>
 
332
 
 
333
<screen>
 
334
<command>sudo /etc/init.d/puppetmaster restart</command>
 
335
</screen>
 
336
 
 
337
      <para>
 
338
      Now everything is configured on the <application>puppet</application> server, it is time to configure the client.  
 
339
      </para>
 
340
 
 
341
      <para>
 
342
      First, configure the <application>puppet agent</application> daemon to start.  Edit <filename>/etc/default/puppet</filename>, changing 
 
343
      <emphasis>START</emphasis> to yes:
 
344
      </para>
 
345
 
 
346
<programlisting>
 
347
START=yes
 
348
</programlisting>
 
349
 
 
350
      <para>
 
351
      Then start the service:
 
352
      </para>
 
353
 
 
354
<screen>
 
355
<command>sudo /etc/init.d/puppet start</command>
 
356
</screen>
 
357
 
 
358
      <para>
 
359
      Back on the <application>puppet</application> server sign the client certificate by entering:
 
360
      </para>
 
361
 
 
362
<screen>
 
363
<command>sudo puppetca --sign meercat02.example.com</command>
 
364
</screen>
 
365
 
 
366
      <para>
 
367
      Check <filename>/var/log/syslog</filename> for any errors with the configuration.  If all goes well the <application>apache2</application>
 
368
      package and it's dependencies will be installed on the <application>puppet</application> client.
 
369
      </para>
 
370
 
 
371
      <note>
 
372
        <para>
 
373
        This example is <emphasis>very</emphasis> simple, and does not highlight many of <application>Puppet's</application> features and 
 
374
        benefits.  For more information see <xref linkend="puppet-resources"/>.
 
375
        </para>
 
376
      </note>
 
377
 
 
378
    </sect2>
 
379
    <sect2 id="puppet-resources" status="review">
 
380
      <title>Resources</title>
 
381
 
 
382
      <itemizedlist>
 
383
        <listitem>
 
384
          <para>
 
385
          See the <ulink url="http://docs.puppetlabs.com/">Official Puppet Documentation</ulink> web site.
 
386
          </para>
 
387
        </listitem>
 
388
        <listitem>
 
389
          <para>
 
390
          Also see <ulink url="http://apress.com/book/view/1590599780">Pulling Strings with Puppet</ulink>.
 
391
          </para>
 
392
        </listitem>
 
393
        <listitem>
 
394
          <para>
 
395
          Another source of additional information is the <ulink url="https://help.ubuntu.com/community/Puppet">Ubuntu Wiki Puppet Page</ulink>.
 
396
          </para>
 
397
        </listitem>
 
398
      </itemizedlist>
 
399
 
 
400
    </sect2>
 
401
  </sect1>
 
402
</chapter>