source: postlfs/security/openssh.xml@ f0225ad

ken/TL2024 lazarus trunk xry111/llvm18
Last change on this file since f0225ad was 133eab2, checked in by Bruce Dubbs <bdubbs@…>, 5 months ago

Initial LFS 12.1 tags

  • Property mode set to 100644
File size: 19.3 KB
RevLine 
[ab4fdfc]1<?xml version="1.0" encoding="UTF-8"?>
[6732c094]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[0931098]4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
[3a37311]7 <!ENTITY openssh-download-http
[c6b192c]8 "https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-&openssh-version;.tar.gz">
[28d1edf]9 <!ENTITY openssh-download-ftp " ">
[bed8f3ef]10 <!ENTITY openssh-md5sum "&openssh-md5sum;">
[41557a5]11 <!ENTITY openssh-size "1.8 MB">
[e628e070]12 <!ENTITY openssh-buildsize "45 MB (add 22 MB for tests)">
[81a0948]13 <!ENTITY openssh-time "0.2 SBU (Using parallelism=4;
[075cb1e]14 running the tests takes about 20 minutes,
[6c6990c]15 irrespective of processor speed)">
[0931098]16]>
17
[e628e070]18 <!-- make check: real 18m13.005s; 9.2p1 3 Feb 2023 -->
19 <!-- make check: real 18m08.654s; 9.3p1 17 Mar 2023 -->
[075cb1e]20
[1708d1e9]21<sect1 id="openssh" xreflabel="OpenSSH-&openssh-version;">
[e4e0d060]22 <?dbhtml filename="openssh.html"?>
23
24 <title>OpenSSH-&openssh-version;</title>
25
[0978e07]26 <indexterm zone="openssh">
27 <primary sortas="a-OpenSSH">OpenSSH</primary>
28 </indexterm>
29
30 <sect2 role="package">
31 <title>Introduction to OpenSSH</title>
32
[8ba08b56]33 <para>
34 The <application>OpenSSH</application> package contains
[45db70f]35 <command>ssh</command> clients and the <command>sshd</command> daemon.
36 This is useful for encrypting authentication and subsequent traffic over
37 a network. The <command>ssh</command> and <command>scp</command> commands
38 are secure implementations of <command>telnet</command> and
39 <command>rcp</command> respectively.
[8ba08b56]40 </para>
[6b5cc24]41
[133eab2]42 &lfs121_checked;
[6b5cc24]43
[e4e0d060]44 <bridgehead renderas="sect3">Package Information</bridgehead>
45 <itemizedlist spacing="compact">
46 <listitem>
[3a37311]47 <para>
48 Download (HTTP): <ulink url="&openssh-download-http;"/>
49 </para>
[e4e0d060]50 </listitem>
51 <listitem>
[3a37311]52 <para>
53 Download (FTP): <ulink url="&openssh-download-ftp;"/>
54 </para>
[e4e0d060]55 </listitem>
56 <listitem>
[3a37311]57 <para>
58 Download MD5 sum: &openssh-md5sum;
59 </para>
[e4e0d060]60 </listitem>
61 <listitem>
[3a37311]62 <para>
63 Download size: &openssh-size;
64 </para>
[e4e0d060]65 </listitem>
66 <listitem>
[3a37311]67 <para>
68 Estimated disk space required: &openssh-buildsize;
69 </para>
[e4e0d060]70 </listitem>
71 <listitem>
[3a37311]72 <para>
73 Estimated build time: &openssh-time;
74 </para>
[e4e0d060]75 </listitem>
76 </itemizedlist>
[479274d]77<!--
[3806235]78 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
79 <itemizedlist spacing="compact">
80 <listitem>
81 <para>
82 Required patch:
[f2cb3164]83 <ulink url="&patch-root;/openssh-&openssh-version;-glibc_2.31_fix-1.patch"/>
[3806235]84 </para>
85 </listitem>
86 </itemizedlist>
[479274d]87-->
[e4e0d060]88 <bridgehead renderas="sect3">OpenSSH Dependencies</bridgehead>
[31427bc]89
[e4e0d060]90 <bridgehead renderas="sect4">Optional</bridgehead>
[3a37311]91 <para role="optional">
[d38746e]92 <xref linkend="gdb"/> (for tests),
[0391649]93 <xref linkend="linux-pam"/> (PAM configuration files from
94 <xref linkend="shadow"/> are used to create openssh ones),
[6ae11da]95 <xref linkend="xorg7-app"/> (or
96 <xref linkend='xorg-env' role='nodep'/>, see Command Explanations),
[3a37311]97 <xref linkend="mitkrb"/>,
[3b88aed]98 <xref linkend="which"/> (for tests),
[cd29bc9]99 <ulink url="https://www.thrysoee.dk/editline/">libedit</ulink>,
100 <ulink url="https://www.libressl.org/">LibreSSL Portable</ulink>,
[6c6990c]101 <ulink url="https://github.com/OpenSC/OpenSC/wiki">OpenSC</ulink>, and
[3a37311]102 <ulink url="http://www.citi.umich.edu/projects/smartcard/sectok.html">libsectok</ulink>
103 </para>
[9561d7e]104
[409e2e7]105 <bridgehead renderas="sect4">Optional Runtime (Used only to gather entropy)</bridgehead>
[3a37311]106 <para role="optional">
[b47d633]107 <!--<xref role="runtime" linkend="openjdk"/>, Not seen in 8.8p1 -->
[96e9478]108 <xref role="runtime" linkend="net-tools"/>, and
109 <xref role="runtime" linkend="sysstat"/>
[3a37311]110 </para>
[e4e0d060]111
112 </sect2>
113
114 <sect2 role="installation">
115 <title>Installation of OpenSSH</title>
116
[3a37311]117 <para>
118 <application>OpenSSH</application> runs as two processes when connecting
119 to other computers. The first process is a privileged process and controls
120 the issuance of privileges as necessary. The second process communicates
121 with the network. Additional installation steps are necessary to set up
122 the proper environment, which are performed by issuing the following
123 commands as the <systemitem class="username">root</systemitem> user:
124 </para>
[e4e0d060]125
[f9f9172]126<screen role="root"><userinput>install -v -g sys -m700 -d /var/lib/sshd &amp;&amp;
[59382ab]127
[6c6990c]128groupadd -g 50 sshd &amp;&amp;
129useradd -c 'sshd PrivSep' \
130 -d /var/lib/sshd \
131 -g sshd \
132 -s /bin/false \
133 -u 50 sshd</userinput></screen>
[479274d]134<!--
[3806235]135 <para>
136 Apply a patch to allow OpenSSH to build and function with
[f2cb3164]137 <application>Glibc-2.31</application> and later:
[3806235]138 </para>
139
[f2cb3164]140<screen><userinput remap="pre">patch -Np1 -i ../openssh-&openssh-version;-glibc_2.31_fix-1.patch</userinput></screen>
[8558044]141-->
[5d2965c]142
143<!-- Applied in 8.5p1
[66d223b]144 <para>
145 First, adapt <application>ssh-copy-id</application> to changes
146 in bash-5.1:
147 </para>
148
149<screen><userinput remap="pre">sed -e '/INSTALLKEYS_SH/s/)//' -e '260a\ )' -i contrib/ssh-copy-id</userinput></screen>
150
[79eec369]151 <para>
152 Next, fix an issue on platforms other than x86_64:
153 </para>
154 <screen><userinput remap="pre">if [ "$(uname -m)" != "x86_64" ]; then
155 l1="#ifdef __NR_pselect6_time64"
156 l2=" SC_ALLOW(__NR_pselect6_time64),"
157 l3="#endif"
158 sed -e "/^#ifdef __NR_read$/ i $l1\n$l2\n$l3" \
159 -i sandbox-seccomp-filter.c
160fi</userinput></screen>
[5d2965c]161-->
[3a37311]162 <para>
163 Install <application>OpenSSH</application> by running the following
164 commands:
165 </para>
[0931098]166
[e7dc117]167<!-- -\-with-md5-passwords used to be here, but a comment inside of a <screen>
168 block leaves an eyesore. -->
[1a3d7fb2]169<screen><userinput>./configure --prefix=/usr \
170 --sysconfdir=/etc/ssh \
171 --with-privsep-path=/var/lib/sshd \
172 --with-default-path=/usr/bin \
173 --with-superuser-path=/usr/sbin:/usr/bin \
[ca65e1e]174 --with-pid-dir=/run &amp;&amp;
[3a3b19b]175make</userinput></screen>
[1b83a7c1]176
[196cbf4]177<!-- I got all tests passed without this with 9.3p1, June 12, 2023.
[3a37311]178 <para>
[48771ae]179 The test suite requires an installed copy of <command>scp</command> to
[bc6e56d]180 complete the multiplexing tests. To run the test suite, first copy the
181 <command>scp</command> program to
182 <filename class="directory">/usr/bin</filename>, making sure that you
[45db70f]183 backup any existing copy first.
[3a37311]184 </para>
[196cbf4]185-->
[81a0948]186<!-- I got all tests passed without this with 9.0p1. Apr 13, 2022.
[9556a94]187 <para>
188 If you wish to run the tests, remove a test suite that is not valid on
189 Linux-based platforms:
190 </para>
191
192<screen><userinput>sed -i 's/conch-ciphers//' regress/Makefile</userinput></screen>
[81a0948]193-->
[5a6a6be]194 <para>
[7c017a3]195 To test the results, issue: <command>make -j1 tests</command>.
[21552cf]196 <!--One test, <filename>key options</filename>, fails when run in chroot.-->
[5a6a6be]197 </para>
198
199<!-- commenting this, I get "all tests passed" [ ken ]
200 NB tests should be run as _user_ but the role in the comment is root
[59382ab]201
202 commenting [ bruce ]: There are a couple of tests that want root.
[6c6990c]203 The log mentions that SUDO is not set. These skipped tests are
[59382ab]204 ignored and the end says 'all tests passed' even when not root
205
[3a37311]206 <para>
207 To run the test suite, issue the following commands:
208 </para>
[7c9e252]209
[409e2e7]210<screen role="root"><userinput>make tests 2&gt;&amp;1 | tee check.log
211grep FATAL check.log</userinput></screen>
[7c9e252]212
[3a37311]213 <para>
214 If the above command produces no 'FATAL' errors, then proceed with the
215 installation, as the <systemitem class="username">root</systemitem> user:
[5a6a6be]216 </para>-->
217 <para>
218 Now, as the <systemitem class="username">root</systemitem> user:
[3a37311]219 </para>
[7c9e252]220
[6c6990c]221<screen role="root"><userinput>make install &amp;&amp;
222install -v -m755 contrib/ssh-copy-id /usr/bin &amp;&amp;
223
224install -v -m644 contrib/ssh-copy-id.1 \
225 /usr/share/man/man1 &amp;&amp;
[5ee1266]226install -v -m755 -d /usr/share/doc/openssh-&openssh-version; &amp;&amp;
[6c6990c]227install -v -m644 INSTALL LICENCE OVERVIEW README* \
228 /usr/share/doc/openssh-&openssh-version;</userinput></screen>
[e4e0d060]229 </sect2>
230
231 <sect2 role="commands">
232 <title>Command Explanations</title>
233
[3a37311]234 <para>
235 <parameter>--sysconfdir=/etc/ssh</parameter>: This prevents the
236 configuration files from being installed in
237 <filename class="directory">/usr/etc</filename>.
238 </para>
239
[1a3d7fb2]240 <para>
241 <parameter>--with-default-path=/usr/bin</parameter> and
242 <parameter>--with-superuser-path=/usr/sbin:/usr/bin</parameter>:
243 These set <envar>PATH</envar> consistent with LFS and BLFS
244 <application>Shadow</application> package.
245 </para>
246
247 <para>
248 <parameter>--with-pid-dir=/run</parameter>: This prevents
[2c87187]249 <application>OpenSSH</application> from referring to deprecated
[1a3d7fb2]250 <filename class="directory">/var/run</filename>.
251 </para>
[875b3b57]252<!--
[ecab0590]253 <para>
[875b3b57]254 <parameter>- -without-zlib-version-check</parameter>: This prevents
[ecab0590]255 <application>OpenSSH</application> from checking the version of
256 the system <application>Zlib</application>. We need to use this
257 switch or the version check would mistakenly report the latest
258 <application>Zlib</application> 1.13 <quote>too old</quote> and
259 reject it.
260 </para>
[875b3b57]261-->
[3a37311]262 <para>
[f1d7196]263 <option>--with-pam</option>: This parameter enables
[3a37311]264 <application>Linux-PAM</application> support in the build.
265 </para>
266
267 <para>
[6ae11da]268 <option>--with-xauth=$XORG_PREFIX/bin/xauth</option>: Set the default
[3a37311]269 location for the <command>xauth</command> binary for X authentication.
[6ae11da]270 The environment variable <envar>XORG_PREFIX</envar> should be set
271 following <xref linkend='xorg-env'/>. This can also be controlled from
[3a37311]272 <filename>sshd_config</filename> with the XAuthLocation keyword. You can
273 omit this switch if <application>Xorg</application> is already installed.
274 </para>
275
276 <para>
[f1d7196]277 <option>--with-kerberos5=/usr</option>: This option is used to
[3a37311]278 include Kerberos 5 support in the build.
279 </para>
[409e2e7]280
[ba0004e]281 <para>
[f1d7196]282 <option>--with-libedit</option>: This option enables line editing
[ba0004e]283 and history features for <command>sftp</command>.
284 </para>
285
[e4e0d060]286 </sect2>
287
288 <sect2 role="configuration">
289 <title>Configuring OpenSSH</title>
290
291 <sect3 id="openssh-config">
292 <title>Config Files</title>
293
[3a37311]294 <para>
295 <filename>~/.ssh/*</filename>,
[e4e0d060]296 <filename>/etc/ssh/ssh_config</filename>, and
[3a37311]297 <filename>/etc/ssh/sshd_config</filename>
298 </para>
[e4e0d060]299
300 <indexterm zone="openssh openssh-config">
301 <primary sortas="e-AA.ssh">~/.ssh/*</primary>
302 </indexterm>
303
304 <indexterm zone="openssh openssh-config">
305 <primary sortas="e-etc-ssh-ssh_config">/etc/ssh/ssh_config</primary>
306 </indexterm>
307
308 <indexterm zone="openssh openssh-config">
309 <primary sortas="e-etc-ssh-sshd_config">/etc/ssh/sshd_config</primary>
310 </indexterm>
311
[3a37311]312 <para>
313 There are no required changes to any of these files. However,
314 you may wish to view the
315 <filename class='directory'>/etc/ssh/</filename> files and make any
316 changes appropriate for the security of your system. One recommended
317 change is that you disable
318 <systemitem class='username'>root</systemitem> login via
319 <command>ssh</command>. Execute the following command as the
320 <systemitem class='username'>root</systemitem> user to disable
321 <systemitem class='username'>root</systemitem> login via
322 <command>ssh</command>:
323 </para>
[e4e0d060]324
[6c24da75]325<screen role="root"><userinput>echo "PermitRootLogin no" &gt;&gt; /etc/ssh/sshd_config</userinput></screen>
326
[3a37311]327 <para>
328 If you want to be able to log in without typing in your password, first
329 create ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub with
330 <command>ssh-keygen</command> and then copy ~/.ssh/id_rsa.pub to
331 ~/.ssh/authorized_keys on the remote computer that you want to log into.
[f507f06]332 You'll need to change REMOTE_USERNAME and REMOTE_HOSTNAME for the username and hostname of the remote
333 computer and you'll also need to enter your password for the ssh-copy-id command
[3a37311]334 to succeed:
335 </para>
336
[71084a84]337<screen role='nodump'><userinput>ssh-keygen &amp;&amp;
[cb4718e]338ssh-copy-id -i ~/.ssh/id_ed25519.pub <replaceable>REMOTE_USERNAME</replaceable>@<replaceable>REMOTE_HOSTNAME</replaceable></userinput></screen>
[3a37311]339
340 <para>
341 Once you've got passwordless logins working it's actually more secure
342 than logging in with a password (as the private key is much longer than
343 most people's passwords). If you would like to now disable password
344 logins, as the <systemitem class="username">root</systemitem> user:
345 </para>
346
347
348<screen role="root"><userinput>echo "PasswordAuthentication no" >> /etc/ssh/sshd_config &amp;&amp;
[4d15c65]349echo "KbdInteractiveAuthentication no" >> /etc/ssh/sshd_config</userinput></screen>
[3a37311]350
351 <para>
[f586237]352 If you added <application>Linux-PAM</application> support and you want
[3a37311]353 ssh to use it then you will need to add a configuration file for
354 <application>sshd</application> and enable use of
355 <application>LinuxPAM</application>. Note, ssh only uses PAM to check
356 passwords, if you've disabled password logins these commands are not
[f586237]357 needed. If you want to use PAM, issue the following commands as the
[3a37311]358 <systemitem class='username'>root</systemitem> user:
359 </para>
[6c24da75]360
361<screen role="root"><userinput>sed 's@d/login@d/sshd@g' /etc/pam.d/login &gt; /etc/pam.d/sshd &amp;&amp;
[b30ddee]362chmod 644 /etc/pam.d/sshd &amp;&amp;
[5a6a6be]363echo "UsePAM yes" &gt;&gt; /etc/ssh/sshd_config</userinput></screen>
[e4e0d060]364
[3a37311]365 <para>
366 Additional configuration information can be found in the man
367 pages for <command>sshd</command>, <command>ssh</command> and
368 <command>ssh-agent</command>.
369 </para>
[e4e0d060]370 </sect3>
371
372 <sect3 id="openssh-init">
[f586237]373 <title><phrase revision="sysv">Boot Script</phrase>
374 <phrase revision="systemd">Systemd Unit</phrase></title>
[e4e0d060]375
[f586237]376 <para revision="sysv">
[3a37311]377 To start the SSH server at system boot, install the
[3c7bd00]378 <filename>/etc/rc.d/init.d/sshd</filename> init script included
[f586237]379 in the <xref linkend="bootscripts"/> package.
380 </para>
381
382 <para revision="systemd">
383 To start the SSH server at system boot, install the
384 <filename>sshd.service</filename> unit included in the
385 <xref linkend="systemd-units"/> package.
[3c7bd00]386 </para>
[e4e0d060]387
388 <indexterm zone="openssh openssh-init">
389 <primary sortas="f-sshd">sshd</primary>
390 </indexterm>
391
392<screen role="root"><userinput>make install-sshd</userinput></screen>
393 </sect3>
394 </sect2>
395
396 <sect2 role="content">
397 <title>Contents</title>
398
399 <segmentedlist>
400 <segtitle>Installed Programs</segtitle>
[c3c56b2]401 <segtitle>Installed Libraries</segtitle>
[e4e0d060]402 <segtitle>Installed Directories</segtitle>
403
404 <seglistitem>
[3a37311]405 <seg>
[5d2965c]406 scp, sftp, <!--slogin (symlink to ssh),--> ssh, ssh-add, ssh-agent,
[b2b7378b]407 ssh-copy-id, ssh-keygen, ssh-keyscan, and sshd
[c3c56b2]408 </seg>
409 <seg>
410 None
[3a37311]411 </seg>
412 <seg>
413 /etc/ssh,
[c175983]414 /usr/share/doc/openssh-&openssh-version;, and
415 /var/lib/sshd
[3a37311]416 </seg>
[e4e0d060]417 </seglistitem>
418 </segmentedlist>
419
420 <variablelist>
421 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
422 <?dbfo list-presentation="list"?>
423 <?dbhtml list-presentation="table"?>
424
425 <varlistentry id="scp">
426 <term><command>scp</command></term>
427 <listitem>
[3a37311]428 <para>
429 is a file copy program that acts like <command>rcp</command> except
[4c24eb0a]430 it uses an encrypted protocol
[3a37311]431 </para>
[e4e0d060]432 <indexterm zone="openssh scp">
433 <primary sortas="b-scp">scp</primary>
434 </indexterm>
435 </listitem>
436 </varlistentry>
437
438 <varlistentry id="sftp">
439 <term><command>sftp</command></term>
440 <listitem>
[3a37311]441 <para>
[4c24eb0a]442 is an FTP-like program that works over the SSH1 and SSH2 protocols
[3a37311]443 </para>
[e4e0d060]444 <indexterm zone="openssh sftp">
445 <primary sortas="b-sftp">sftp</primary>
446 </indexterm>
447 </listitem>
448 </varlistentry>
[5d2965c]449<!-- Not installed anymore as of 8.5p1
[e4e0d060]450 <varlistentry id="slogin">
451 <term><command>slogin</command></term>
452 <listitem>
[3a37311]453 <para>
[4c24eb0a]454 is a symlink to <command>ssh</command>
[3a37311]455 </para>
[e4e0d060]456 <indexterm zone="openssh slogin">
[b960e3ec]457 <primary sortas="b-slogin">slogin</primary>
[e4e0d060]458 </indexterm>
459 </listitem>
460 </varlistentry>
[5d2965c]461-->
[e4e0d060]462 <varlistentry id="ssh">
463 <term><command>ssh</command></term>
464 <listitem>
[3a37311]465 <para>
466 is an <command>rlogin</command>/<command>rsh</command>-like client
[4c24eb0a]467 program except it uses an encrypted protocol
[3a37311]468 </para>
[e4e0d060]469 <indexterm zone="openssh ssh">
470 <primary sortas="b-ssh">ssh</primary>
471 </indexterm>
472 </listitem>
473 </varlistentry>
474
475 <varlistentry id="sshd">
476 <term><command>sshd</command></term>
477 <listitem>
[3a37311]478 <para>
[4c24eb0a]479 is a daemon that listens for <command>ssh</command> login requests
[3a37311]480 </para>
[e4e0d060]481 <indexterm zone="openssh sshd">
482 <primary sortas="b-sshd">sshd</primary>
483 </indexterm>
484 </listitem>
485 </varlistentry>
486
487 <varlistentry id="ssh-add">
488 <term><command>ssh-add</command></term>
489 <listitem>
[3a37311]490 <para>
[4c24eb0a]491 is a tool which adds keys to the <command>ssh-agent</command>
[3a37311]492 </para>
[e4e0d060]493 <indexterm zone="openssh ssh-add">
494 <primary sortas="b-ssh-add">ssh-add</primary>
495 </indexterm>
496 </listitem>
497 </varlistentry>
498
499 <varlistentry id="ssh-agent">
500 <term><command>ssh-agent</command></term>
501 <listitem>
[3a37311]502 <para>
[4c24eb0a]503 is an authentication agent that can store private keys
[3a37311]504 </para>
[e4e0d060]505 <indexterm zone="openssh ssh-agent">
506 <primary sortas="b-ssh-agent">ssh-agent</primary>
507 </indexterm>
508 </listitem>
509 </varlistentry>
510
[5a2f5972]511 <varlistentry id="ssh-copy-id">
512 <term><command>ssh-copy-id</command></term>
513 <listitem>
514 <para>
[5d2965c]515 is a script that enables logins on remote machines using local keys
[5a2f5972]516 </para>
517 <indexterm zone="openssh ssh-copy-id">
518 <primary sortas="b-ssh-copy-id">ssh-copy-id</primary>
519 </indexterm>
520 </listitem>
521 </varlistentry>
522
[e4e0d060]523 <varlistentry id="ssh-keygen">
524 <term><command>ssh-keygen</command></term>
525 <listitem>
[3a37311]526 <para>
[4c24eb0a]527 is a key generation tool
[3a37311]528 </para>
[e4e0d060]529 <indexterm zone="openssh ssh-keygen">
530 <primary sortas="b-ssh-keygen">ssh-keygen</primary>
531 </indexterm>
532 </listitem>
533 </varlistentry>
534
535 <varlistentry id="ssh-keyscan">
536 <term><command>ssh-keyscan</command></term>
537 <listitem>
[3a37311]538 <para>
[4c24eb0a]539 is a utility for gathering public host keys from a number of hosts
[3a37311]540 </para>
[e4e0d060]541 <indexterm zone="openssh ssh-keyscan">
542 <primary sortas="b-ssh-keyscan">ssh-keyscan</primary>
543 </indexterm>
544 </listitem>
545 </varlistentry>
546
547 </variablelist>
548 </sect2>
[4c24eb0a]549
[e4e0d060]550</sect1>
Note: See TracBrowser for help on using the repository browser.