~kim0/serverguide/serverguide-review-ch19

« back to all changes in this revision

Viewing changes to build/serverguide/C/openssh-server.html

  • 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" standalone="no"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml">
 
4
  <head xmlns="http://www.w3.org/1999/xhtml">
 
5
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
6
    <title xmlns="">OpenSSH Server</title>
 
7
    <link rel="stylesheet" href="../../libs/ubuntu-book.css" type="text/css" />
 
8
    <link rel="home" href="index.html" title="Ubuntu Server Guide" />
 
9
    <link rel="up" href="remote-administration.html" title="Chapter 5. Remote Administration" />
 
10
    <link rel="prev" href="remote-administration.html" title="Chapter 5. Remote Administration" />
 
11
    <link rel="next" href="puppet.html" title="Puppet" />
 
12
    <link rel="copyright" href="legal.html" title="Credits and License" />
 
13
  </head>
 
14
  <body>
 
15
    <div id="round">
 
16
      <img id="topcap" alt="" src="https://help.ubuntu.com/htdocs/ubuntunew/img/cap-top.png" />
 
17
      <div id="layout" class="container clear-block">
 
18
        <script xmlns="" src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>
 
19
        <script xmlns="" type="text/javascript">
 
20
_uacct = "UA-1018242-8";
 
21
urchinTracker();
 
22
</script>
 
23
        <div id="header">
 
24
          <div id="logo-floater">
 
25
            <h1>
 
26
              <a href="https://help.ubuntu.com" title="Ubuntu Documentation">
 
27
                <img alt="Ubuntu" id="logo" src="https://help.ubuntu.com/htdocs/ubuntunew/img/logo.png" />
 
28
              </a>
 
29
            </h1>
 
30
          </div>
 
31
          <noscript>
 
32
            <form action="http://www.google.com/cse" id="cse-search-box">
 
33
              <div>
 
34
                <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq" />
 
35
                <input type="hidden" name="ie" value="UTF-8" />
 
36
                <input type="text" name="q" size="27" />
 
37
                <input type="submit" name="sa" value="Search" />
 
38
              </div>
 
39
            </form>
 
40
          </noscript>
 
41
          <script>
 
42
 document.write('<form action="https://help.ubuntu.com/search.html" id="cse-search-box">');
 
43
 document.write('  <div>');
 
44
 document.write('    <input type="hidden" name="cof" value="FORID:9" />');
 
45
 document.write('    <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq" />');
 
46
 document.write('    <input type="hidden" name="ie" value="UTF-8" />');
 
47
 document.write('    <input type="text" name="q" size="27" />');
 
48
 document.write('    <input type="submit" name="sa" value="Search" />');
 
49
 document.write('  </div>');
 
50
 document.write('</form>');
 
51
</script>
 
52
          <div id="sitename">
 
53
            <a href="https://help.ubuntu.com/">
 
54
              <img alt="Official Documentation" src="https://help.ubuntu.com/htdocs/ubuntunew/img/help-about.png" />
 
55
              <span>Official Documentation</span>
 
56
            </a>
 
57
          </div>
 
58
        </div>
 
59
        <div id="page">
 
60
          <div id="content">
 
61
            <div class="breadcrumbs"><a href="https://help.ubuntu.com/">Ubuntu Documentation</a> &gt; <a href="https://help.ubuntu.com/11.04">Ubuntu 11.04</a> &gt; <span class="breadcrumb-link"><a href="index.html">Ubuntu Server Guide</a></span> &gt; <span class="breadcrumb-link"><a href="remote-administration.html">Remote Administration</a></span> &gt; <span class="breadcrumb-node">OpenSSH Server</span></div>
 
62
            <div xmlns="http://www.w3.org/1999/xhtml" class="sect1" title="OpenSSH Server">
 
63
              <div class="titlepage">
 
64
                <div>
 
65
                  <div>
 
66
                    <h2 class="title" style="clear: both"><a id="openssh-server"></a>OpenSSH Server</h2>
 
67
                  </div>
 
68
                </div>
 
69
              </div>
 
70
              <div class="sect2" title="Introduction">
 
71
                <div class="titlepage">
 
72
                  <div>
 
73
                    <div>
 
74
                      <h3 class="title"><a id="openssh-introduction"></a>Introduction</h3>
 
75
                    </div>
 
76
                  </div>
 
77
                </div>
 
78
                <p>
 
79
            This section of the Ubuntu Server Guide introduces a powerful collection of tools
 
80
            for the remote control of networked computers and transfer of data between 
 
81
            networked computers, called <span class="emphasis"><em>OpenSSH</em></span>. You will also learn
 
82
            about some of the configuration settings possible with the OpenSSH server 
 
83
            application and how to change them on your Ubuntu system. 
 
84
          </p>
 
85
                <p>
 
86
            OpenSSH is a freely available version of the Secure Shell (SSH) protocol family of 
 
87
            tools for remotely controlling a computer or transferring files between computers.
 
88
            Traditional tools used to accomplish these functions, such as 
 
89
            <span class="application"><strong>telnet</strong></span> or <span class="application"><strong>rcp</strong></span>, are insecure 
 
90
            and transmit the user's password in cleartext when used. OpenSSH provides a server 
 
91
            daemon and client tools to facilitate secure, encrypted remote control and file 
 
92
            transfer operations, effectively replacing the legacy tools.
 
93
          </p>
 
94
                <p>
 
95
            The OpenSSH server component, <span class="application"><strong>sshd</strong></span>, listens 
 
96
            continuously for client connections from any of the client tools. When a connection 
 
97
            request occurs, <span class="application"><strong>sshd</strong></span> sets up the correct connection 
 
98
            depending on the type of client tool connecting. For example, if the remote 
 
99
            computer is connecting with the <span class="application"><strong>ssh</strong></span> client application, 
 
100
            the OpenSSH server sets up a remote control session after authentication. If a 
 
101
            remote user connects to an OpenSSH server with <span class="application"><strong>scp</strong></span>, the 
 
102
            OpenSSH server daemon initiates a secure copy of files between the server and 
 
103
            client after authentication. OpenSSH can use many authentication methods, including             plain password, public key, and <span class="application"><strong>Kerberos</strong></span> tickets.
 
104
            </p>
 
105
              </div>
 
106
              <div class="sect2" title="Installation">
 
107
                <div class="titlepage">
 
108
                  <div>
 
109
                    <div>
 
110
                      <h3 class="title"><a id="openssh-installation"></a>Installation</h3>
 
111
                    </div>
 
112
                  </div>
 
113
                </div>
 
114
                <p>
 
115
        Installation of the OpenSSH client and server applications is simple. To install the 
 
116
        OpenSSH client applications on your Ubuntu system, use this command at a terminal 
 
117
        prompt:
 
118
        </p>
 
119
                <pre class="screen">
 
120
<span class="command"><strong>sudo apt-get install openssh-client</strong></span>
 
121
</pre>
 
122
                <p>
 
123
        To install the OpenSSH server application, and related support files, use this command 
 
124
        at a terminal prompt:
 
125
        </p>
 
126
                <pre class="screen">
 
127
<span class="command"><strong>sudo apt-get install openssh-server</strong></span>
 
128
</pre>
 
129
                <p>
 
130
        The <span class="application"><strong>openssh-server</strong></span> package can also be selected to 
 
131
        install during the Server Edition installation process.
 
132
        </p>
 
133
              </div>
 
134
              <div class="sect2" title="Configuration">
 
135
                <div class="titlepage">
 
136
                  <div>
 
137
                    <div>
 
138
                      <h3 class="title"><a id="openssh-configuration"></a>Configuration</h3>
 
139
                    </div>
 
140
                  </div>
 
141
                </div>
 
142
                <p>
 
143
          You may configure the default behavior of the OpenSSH server application, 
 
144
          <span class="application"><strong>sshd</strong></span>, by editing the file 
 
145
          <code class="filename">/etc/ssh/sshd_config</code>. For information about the configuration 
 
146
          directives used in this file, you may view the appropriate manual page with the 
 
147
          following command, issued at a terminal prompt:
 
148
          </p>
 
149
                <pre class="screen">
 
150
<span class="command"><strong>man sshd_config</strong></span>
 
151
</pre>
 
152
                <p>
 
153
            There are many directives in the <span class="application"><strong>sshd</strong></span> configuration 
 
154
            file controlling such things as communication settings and authentication modes. 
 
155
            The following are examples of configuration directives that can be changed by 
 
156
            editing the <code class="filename">/etc/ssh/sshd_config</code> file.
 
157
            </p>
 
158
                <div class="tip" title="Tip" style="margin-left: 0.5in; margin-right: 0.5in;">
 
159
                  <table border="0" summary="Tip">
 
160
                    <tr>
 
161
                      <td rowspan="2" align="center" valign="top" width="25">
 
162
                        <img alt="[Tip]" src="../../libs/admon/tip.png" />
 
163
                      </td>
 
164
                      <th align="left"></th>
 
165
                    </tr>
 
166
                    <tr>
 
167
                      <td align="left" valign="top">
 
168
                        <p>Prior to editing the configuration file, you should make a copy of the 
 
169
                original file and protect it from writing so you will have the original 
 
170
                settings as a reference and to reuse as necessary.
 
171
                </p>
 
172
                        <p>Copy the <code class="filename">/etc/ssh/sshd_config</code> file and protect it 
 
173
                from writing with the following commands, issued at a terminal prompt:
 
174
                </p>
 
175
                      </td>
 
176
                    </tr>
 
177
                  </table>
 
178
                </div>
 
179
                <pre class="screen">
 
180
<span class="command"><strong>sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original</strong></span>
 
181
<span class="command"><strong>sudo chmod a-w /etc/ssh/sshd_config.original</strong></span>
 
182
</pre>
 
183
                <p>
 
184
            The following are examples of configuration directives you may change:
 
185
            </p>
 
186
                <div class="itemizedlist">
 
187
                  <ul class="itemizedlist" type="disc">
 
188
                    <li class="listitem">
 
189
                      <p>
 
190
               To set your OpenSSH to listen on TCP port 2222 instead of the default TCP port 
 
191
               22, change the Port directive as such:
 
192
               </p>
 
193
                      <p>
 
194
               Port 2222
 
195
               </p>
 
196
                    </li>
 
197
                    <li class="listitem">
 
198
                      <p>
 
199
            To have <span class="application"><strong>sshd</strong></span> allow public key-based login credentials, 
 
200
            simply add or modify the line:
 
201
            </p>
 
202
                      <p>
 
203
               PubkeyAuthentication yes
 
204
               </p>
 
205
                      <p>
 
206
            In the <code class="filename">/etc/ssh/sshd_config</code> file, or if already present, 
 
207
            ensure the line is not commented out.
 
208
            </p>
 
209
                    </li>
 
210
                    <li class="listitem">
 
211
                      <p>
 
212
             To make your OpenSSH server display the contents of the 
 
213
             <code class="filename">/etc/issue.net</code> file as a pre-login
 
214
             banner, simply add or modify the line:
 
215
             </p>
 
216
                      <p>
 
217
               Banner  /etc/issue.net
 
218
               </p>
 
219
                      <p>
 
220
               In the <code class="filename">/etc/ssh/sshd_config</code> file.
 
221
               </p>
 
222
                    </li>
 
223
                  </ul>
 
224
                </div>
 
225
                <p>
 
226
            After making changes to the <code class="filename">/etc/ssh/sshd_config</code> file, save 
 
227
            the file, and restart the <span class="application"><strong>sshd</strong></span> server application to 
 
228
            effect the changes using the following command at a terminal prompt:
 
229
            </p>
 
230
                <pre class="screen">
 
231
<span class="command"><strong>sudo /etc/init.d/ssh restart</strong></span>
 
232
</pre>
 
233
                <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
 
234
                  <table border="0" summary="Warning">
 
235
                    <tr>
 
236
                      <td rowspan="2" align="center" valign="top" width="25">
 
237
                        <img alt="[Warning]" src="../../libs/admon/warning.png" />
 
238
                      </td>
 
239
                      <th align="left"></th>
 
240
                    </tr>
 
241
                    <tr>
 
242
                      <td align="left" valign="top">
 
243
                        <p>
 
244
                  Many other configuration directives for <span class="application"><strong>sshd</strong></span> are 
 
245
                  available for changing the server application's behavior to fit your needs. 
 
246
                  Be advised, however, if your only method of access to a server is 
 
247
                  <span class="application"><strong>ssh</strong></span>, and you make a mistake in configuring 
 
248
                  <span class="application"><strong>sshd</strong></span> via the 
 
249
                  <code class="filename">/etc/ssh/sshd_config</code> file, you may find you
 
250
                  are locked out of the server upon restarting it, or that the 
 
251
                  <span class="application"><strong>sshd</strong></span> server refuses to start due to an incorrect 
 
252
                  configuration directive, so be extra careful when editing this file on a 
 
253
                  remote server.
 
254
                  </p>
 
255
                      </td>
 
256
                    </tr>
 
257
                  </table>
 
258
                </div>
 
259
              </div>
 
260
              <div class="sect2" title="SSH Keys">
 
261
                <div class="titlepage">
 
262
                  <div>
 
263
                    <div>
 
264
                      <h3 class="title"><a id="openssh-keys"></a>SSH Keys</h3>
 
265
                    </div>
 
266
                  </div>
 
267
                </div>
 
268
                <p>
 
269
     SSH <span class="emphasis"><em>keys</em></span> allow authentication between two hosts without the need of a password.  SSH key authentication 
 
270
     uses two keys a <span class="emphasis"><em>private</em></span> key and a <span class="emphasis"><em>public</em></span> key.
 
271
     </p>
 
272
                <p>
 
273
     To generate the keys, from a terminal prompt enter:
 
274
     </p>
 
275
                <pre class="screen">
 
276
<span class="command"><strong>ssh-keygen -t dsa</strong></span>
 
277
</pre>
 
278
                <p>
 
279
     This will generate the keys using a <span class="emphasis"><em>DSA</em></span> authentication identity of the user.  During the process you
 
280
     will be prompted for a password.  Simply hit <span class="emphasis"><em>Enter</em></span> when prompted to create the key.  
 
281
     </p>
 
282
                <p>
 
283
     By default the <span class="emphasis"><em>public</em></span> key is saved in the file <code class="filename">~/.ssh/id_dsa.pub</code>, while 
 
284
     <code class="filename">~/.ssh/id_dsa</code> is the <span class="emphasis"><em>private</em></span> key.  Now copy the <code class="filename">id_dsa.pub</code> file
 
285
     to the remote host and append it to <code class="filename">~/.ssh/authorized_keys</code> by entering:
 
286
     </p>
 
287
                <pre class="screen">
 
288
<span class="command"><strong>ssh-copy-id username@remotehost</strong></span>
 
289
</pre>
 
290
                <p>
 
291
     Finally, double check the permissions on the <code class="filename">authorized_keys</code> file, only the authenticated user should have read and write permissions.
 
292
     If the permissions are not correct change them by:
 
293
     </p>
 
294
                <pre class="screen">
 
295
<span class="command"><strong>chmod 600 .ssh/authorized_keys</strong></span>
 
296
</pre>
 
297
                <p>
 
298
     You should now be able to SSH to the host without being prompted for a password.
 
299
     </p>
 
300
              </div>
 
301
              <div class="sect2" title="References">
 
302
                <div class="titlepage">
 
303
                  <div>
 
304
                    <div>
 
305
                      <h3 class="title"><a id="openssh-references"></a>References</h3>
 
306
                    </div>
 
307
                  </div>
 
308
                </div>
 
309
                <div class="itemizedlist">
 
310
                  <ul class="itemizedlist" type="disc">
 
311
                    <li class="listitem">
 
312
                      <p>
 
313
          <a class="ulink" href="https://help.ubuntu.com/community/SSH" target="_top">Ubuntu Wiki SSH</a> page.
 
314
          </p>
 
315
                    </li>
 
316
                    <li class="listitem">
 
317
                      <p>
 
318
          <a class="ulink" href="http://www.openssh.org/" target="_top">OpenSSH Website</a>
 
319
          </p>
 
320
                    </li>
 
321
                    <li class="listitem">
 
322
                      <p>
 
323
          <a class="ulink" href="https://wiki.ubuntu.com/AdvancedOpenSSH" target="_top">Advanced OpenSSH Wiki Page</a>
 
324
          </p>
 
325
                    </li>
 
326
                  </ul>
 
327
                </div>
 
328
              </div>
 
329
            </div>
 
330
          </div>
 
331
          <div xmlns="http://www.w3.org/1999/xhtml" class="navfooter">
 
332
            <hr />
 
333
            <table width="100%" summary="Navigation footer">
 
334
              <tr>
 
335
                <td width="40%" align="left"><a accesskey="p" href="remote-administration.html"><img src="../../libs/navig/prev.png" alt="Prev" /></a> </td>
 
336
                <td width="20%" align="center">
 
337
                  <a accesskey="u" href="remote-administration.html">
 
338
                    <img src="../../libs/navig/up.png" alt="Up" />
 
339
                  </a>
 
340
                </td>
 
341
                <td width="40%" align="right"> <a accesskey="n" href="puppet.html"><img src="../../libs/navig/next.png" alt="Next" /></a></td>
 
342
              </tr>
 
343
              <tr>
 
344
                <td width="40%" align="left" valign="top">Chapter 5. Remote Administration </td>
 
345
                <td width="20%" align="center">
 
346
                  <a accesskey="h" href="index.html">
 
347
                    <img src="../../libs/navig/home.png" alt="Home" />
 
348
                  </a>
 
349
                </td>
 
350
                <td width="40%" align="right" valign="top"> Puppet</td>
 
351
              </tr>
 
352
            </table>
 
353
          </div>
 
354
          <hr />
 
355
          <div id="footer">
 
356
            <div id="ubuntulinks">
 
357
              <p>The material in this document is available under a free license, see <a href="/legal.html">Legal</a> for details<br />
 
358
        For information on contributing see the <a href="https://wiki.ubuntu.com/DocumentationTeam">Ubuntu Documentation Team wiki page</a>. To report a problem, visit the <a href="https://bugs.launchpad.net/ubuntu/+source/ubuntu-docs">bug page for Ubuntu Documentation</a></p>
 
359
            </div>
 
360
          </div>
 
361
          <div id="bottomcap">
 
362
            <img src="https://help.ubuntu.com/htdocs/ubuntunew/img/cap-bottom.png" alt="" />
 
363
          </div>
 
364
        </div>
 
365
      </div>
 
366
    </div>
 
367
  </body>
 
368
</html>