View | Details | Raw Unified | Return to bug 105456
Collapse All | Expand All

(-)doc/en_US.ISO8859-1/books/handbook/security/chapter.sgml (-319 / +387 lines)
Lines 66-82 Link Here
66
      </listitem>
66
      </listitem>
67
67
68
      <listitem>
68
      <listitem>
69
	<para>How to configure IPsec and create a <acronym>VPN</acronym> between
69
	<para>How to configure IPsec and create a 
70
	&os;/&windows; machines.</para>
70
	  <acronym role="Virual Private Network">VPN</acronym> between
71
	  &os;/&windows; machines. </para>
71
      </listitem>
72
      </listitem>
72
     
73
     
73
      <listitem>
74
      <listitem>
74
	<para>How to configure and use <application>OpenSSH</application>, &os;'s <acronym>SSH</acronym>
75
	<para>How to configure and use <application>OpenSSH</application>
75
	  implementation.</para>
76
	  , &os;'s <acronym role="Secure Shell">SSH</acronym> implementation.
77
	  </para>
76
      </listitem>
78
      </listitem>
77
79
78
      <listitem>
80
      <listitem>
79
	<para>What file system <acronym>ACL</acronym>s are and how to use them.</para>
81
	<para>What file system <acronym role="Access Control Lists">ACL</acronym>s
82
	  are and how to use them.</para>
80
      </listitem>
83
      </listitem>
81
84
82
      <listitem>
85
      <listitem>
Lines 128-142 Link Here
128
      inter-networked, security becomes an even bigger issue.</para>
131
      inter-networked, security becomes an even bigger issue.</para>
129
132
130
    <para>System security also pertains to dealing with various forms of
133
    <para>System security also pertains to dealing with various forms of
131
      attack, including attacks that attempt to crash, or otherwise make a
134
      attacks, including attacks that attempt to crash, or otherwise make a
132
      system unusable, but do not attempt to compromise the
135
      system unusable, but do not attempt to compromise the
133
      <username>root</username> account (<quote>break root</quote>).
136
      <username>root</username> account (<quote>break root</quote>).
134
      Security concerns
137
      Security concerns can be split up into several categories:</para>
135
      can be split up into several categories:</para>
136
138
137
    <orderedlist>
139
    <orderedlist>
138
      <listitem>
140
      <listitem>
139
	<para>Denial of service attacks.</para>
141
	<para>Denial of service (DoS) attacks.</para>
140
      </listitem>
142
      </listitem>
141
143
142
      <listitem>
144
      <listitem>
Lines 168-181 Link Here
168
    <indexterm><primary>Denial of Service (DoS)</primary></indexterm>
170
    <indexterm><primary>Denial of Service (DoS)</primary></indexterm>
169
171
170
    <para>A denial of service attack is an action that deprives the
172
    <para>A denial of service attack is an action that deprives the
171
      machine of needed resources.  Typically, DoS attacks are
173
      machine of needed resources.  Typically, <acronym>DoS</acronym> attacks
172
      brute-force mechanisms that attempt to crash or otherwise make a
174
      are brute-force mechanisms that attempt to crash or otherwise make a
173
      machine unusable by overwhelming its servers or network stack.  Some
175
      machine unusable by overwhelming its servers or network stack.  Some
174
      DoS attacks try to take advantage of bugs in the networking
176
      <acronym>DoS</acronym> attacks try to take advantage of bugs in the
175
      stack to crash a machine with a single packet.  The latter can only
177
      networking stack to crash a machine with a single packet.  The latter
176
      be fixed by applying a bug fix to the kernel.  Attacks on servers
178
      can only be fixed by applying a bug fix to the kernel.  Attacks on
177
      can often be fixed by properly specifying options to limit the load
179
      servers can often be fixed by properly specifying options to limit the
178
      the servers incur on the system under adverse conditions.
180
      load the servers incur on the system under adverse conditions.
179
      Brute-force network attacks are harder to deal with.  A
181
      Brute-force network attacks are harder to deal with.  A
180
      spoofed-packet attack, for example, is nearly impossible to stop,
182
      spoofed-packet attack, for example, is nearly impossible to stop,
181
      short of cutting your system off from the Internet.  It may not be
183
      short of cutting your system off from the Internet.  It may not be
Lines 187-194 Link Here
187
      <secondary>account compromises</secondary>
189
      <secondary>account compromises</secondary>
188
    </indexterm>
190
    </indexterm>
189
191
190
    <para>A user account compromise is even more common than a DoS
192
    <para>A user account compromise is even more common than a
191
      attack.  Many sysadmins still run standard 
193
      <acronym>DoS</acronym> attack.  Many sysadmins still run standard 
192
      <application>telnetd</application>, <application>rlogind</application>,
194
      <application>telnetd</application>, <application>rlogind</application>,
193
      <application>rshd</application>,
195
      <application>rshd</application>,
194
      and <application>ftpd</application> servers on their machines.
196
      and <application>ftpd</application> servers on their machines.
Lines 226-232 Link Here
226
      a suid-root program that allows the attacker to break
228
      a suid-root program that allows the attacker to break
227
      <username>root</username> once he has broken into a user's account.
229
      <username>root</username> once he has broken into a user's account.
228
      If an attacker has found a way to break <username>root</username>
230
      If an attacker has found a way to break <username>root</username>
229
      on a machine, the attacker may not have a need
231
      on a machine, the attacker may have the need
230
      to install a backdoor.  Many of the <username>root</username> holes
232
      to install a backdoor.  Many of the <username>root</username> holes
231
      found and closed to date involve a considerable amount of work
233
      found and closed to date involve a considerable amount of work
232
      by the attacker to cleanup after himself, so most attackers install
234
      by the attacker to cleanup after himself, so most attackers install
Lines 294-302 Link Here
294
       <application>bold</application> text to refer to an
296
       <application>bold</application> text to refer to an
295
       application, and a <command>monospaced</command> font to refer
297
       application, and a <command>monospaced</command> font to refer
296
       to specific commands.  Protocols will use a normal font.  This
298
       to specific commands.  Protocols will use a normal font.  This
297
       typographical distinction is useful for instances such as ssh,
299
       typographical distinction is useful for instances such as SSH,
298
       since it is
300
       since it is a protocol as well as command.</para>
299
       a protocol as well as command.</para>
300
    </note>
301
    </note>
301
302
302
    <para>The sections that follow will cover the methods of securing your
303
    <para>The sections that follow will cover the methods of securing your
Lines 348-355 Link Here
348
	<groupname>wheel</groupname> group are allowed to
349
	<groupname>wheel</groupname> group are allowed to
349
	<command>su</command> to <username>root</username>.
350
	<command>su</command> to <username>root</username>.
350
	You should never give staff
351
	You should never give staff
351
	members native <groupname>wheel</groupname> access by putting them in the
352
	members native <groupname>wheel</groupname> access by putting them in
352
	<groupname>wheel</groupname> group in their password entry.  Staff
353
	the <groupname>wheel</groupname> group in their password entry.  Staff
353
	accounts should be placed in a <groupname>staff</groupname> group, and
354
	accounts should be placed in a <groupname>staff</groupname> group, and
354
	then added to the <groupname>wheel</groupname> group via the
355
	then added to the <groupname>wheel</groupname> group via the
355
	<filename>/etc/group</filename> file.  Only those staff members
356
	<filename>/etc/group</filename> file.  Only those staff members
Lines 565-571 Link Here
565
	have sufficient control, then you may win out and be able to secure
566
	have sufficient control, then you may win out and be able to secure
566
	the user accounts properly.  If not, you simply have to be more
567
	the user accounts properly.  If not, you simply have to be more
567
	vigilant in your monitoring of those accounts.  Use of
568
	vigilant in your monitoring of those accounts.  Use of
568
	ssh and Kerberos for user accounts is
569
	SSH and Kerberos for user accounts is
569
	more problematic, due to the extra administration and technical
570
	more problematic, due to the extra administration and technical
570
	support required, but still a very good solution compared to a
571
	support required, but still a very good solution compared to a
571
	encrypted password file.</para>
572
	encrypted password file.</para>
Lines 575-581 Link Here
575
      <title>Securing the Password File</title>
576
      <title>Securing the Password File</title>
576
577
577
      <para>The only sure fire way is to star out as many
578
      <para>The only sure fire way is to star out as many
578
	passwords as you can and use ssh or
579
	passwords as you can and use SSH or
579
	Kerberos for access to those accounts.  Even though the encrypted
580
	Kerberos for access to those accounts.  Even though the encrypted
580
	password file (<filename>/etc/spwd.db</filename>) can only be read
581
	password file (<filename>/etc/spwd.db</filename>) can only be read
581
	by <username>root</username>, it may be possible for an intruder
582
	by <username>root</username>, it may be possible for an intruder
Lines 663-671 Link Here
663
	have to give the limited-access box significant access to the
664
	have to give the limited-access box significant access to the
664
	other machines in the business, usually either by doing a
665
	other machines in the business, usually either by doing a
665
	read-only NFS export of the other machines to the limited-access
666
	read-only NFS export of the other machines to the limited-access
666
	box, or by setting up ssh key-pairs to
667
	box, or by setting up SSH key-pairs to
667
	allow the limited-access box to ssh to
668
	allow the limited-access box to use <application>ssh</application> to
668
	the other machines.  Except for its network traffic, NFS is the
669
	access the other machines.  Except for its network traffic, NFS is the
669
	least visible method &mdash; allowing you to monitor the
670
	least visible method &mdash; allowing you to monitor the
670
	file systems on each client box virtually undetected.  If your
671
	file systems on each client box virtually undetected.  If your
671
	limited-access server is connected to the client boxes through a
672
	limited-access server is connected to the client boxes through a
Lines 674-681 Link Here
674
	hub, or through several layers of routing, the NFS method may be
675
	hub, or through several layers of routing, the NFS method may be
675
	too insecure (network-wise) and using
676
	too insecure (network-wise) and using
676
	ssh may be the better choice even with
677
	ssh may be the better choice even with
677
	the audit-trail tracks that ssh
678
	the audit-trail tracks that SSH lays.</para>
678
	lays.</para>
679
679
680
      <para>Once you have given a limited-access box at least read access to the
680
      <para>Once you have given a limited-access box at least read access to the
681
	client systems it is supposed to monitor, you must write scripts
681
	client systems it is supposed to monitor, you must write scripts
Lines 694-706 Link Here
694
694
695
      <para>When using ssh rather than NFS,
695
      <para>When using ssh rather than NFS,
696
	writing the security script is much more difficult.   You
696
	writing the security script is much more difficult.   You
697
	essentially have to <command>scp</command> the scripts to the client 
697
	essentially have to <command>scp</command> the scripts to the client
698
	box in order to
698
	box in order to
699
	run them, making them visible, and for safety you also need to
699
	run them, making them visible, and for safety you also need to
700
	<command>scp</command> the binaries (such as find) that those
700
	<command>scp</command> the binaries (such as find) that those
701
	scripts use.  The <application>ssh</application> client on the
701
	scripts use.  The <application>ssh</application> client on the
702
	client box may already be compromised.  All in all, using
702
	client box may already be compromised.  All in all, using
703
	ssh may be necessary when running over
703
	SSH may be necessary when running over
704
	insecure links, but it is also a lot harder to deal with.</para>
704
	insecure links, but it is also a lot harder to deal with.</para>
705
705
706
      <para>A good security script will also check for changes to user and
706
      <para>A good security script will also check for changes to user and
Lines 753-760 Link Here
753
      <title>Denial of Service Attacks</title>
753
      <title>Denial of Service Attacks</title>
754
      <indexterm><primary>Denial of Service (DoS)</primary></indexterm>
754
      <indexterm><primary>Denial of Service (DoS)</primary></indexterm>
755
755
756
      <para>This section covers Denial of Service attacks.  A DoS attack
756
      <para>This section covers Denial of Service attacks.  A
757
	is typically a packet attack.  While there is not much you can do
757
        <acronym role="Denial of Service">DoS</acronym> attack is typically
758
	a packet attack.  While there is not much you can do
758
	about modern spoofed packet attacks that saturate your network,
759
	about modern spoofed packet attacks that saturate your network,
759
	you can generally limit the damage by ensuring that the attacks
760
	you can generally limit the damage by ensuring that the attacks
760
	cannot take down your servers by:</para>
761
	cannot take down your servers by:</para>
Lines 774-789 Link Here
774
	</listitem>
775
	</listitem>
775
      </orderedlist>
776
      </orderedlist>
776
777
777
      <para>A common DoS attack scenario is attacking a forking server and
778
      <para>A common <acronym>DoS</acronym> attack scenario is attacking a
778
	making it spawning so many child processes that the host system
779
        forking server and making it spawning so many child processes that the
779
	eventually runs out of memory, file descriptors, etc. and then
780
	host system eventually runs out of memory, file descriptors, etc. and
780
	grinds to a halt.  <application>inetd</application> 
781
	then grinds to a halt.  The <application>inetd</application>
781
	(see &man.inetd.8;) has several
782
	application (see &man.inetd.8;) has several
782
	options to limit this sort of attack.  It should be noted that
783
	options to limit this sort of attack.  It should be noted that
783
	while it is possible to prevent a machine from going down, it is
784
	while it is possible to prevent a machine from going down, it is
784
	not generally possible to prevent a service from being disrupted
785
	not generally possible to prevent a service from being disrupted
785
	by the attack.  Read the <application>inetd</application> manual
786
	by the attack.  Read the <application>inetd</application> manual
786
	page carefully and pay
787
	page &man.inetd.8; carefully and pay
787
	specific attention to the <option>-c</option>, <option>-C</option>,
788
	specific attention to the <option>-c</option>, <option>-C</option>,
788
	and <option>-R</option> options.  Note that spoofed-IP attacks
789
	and <option>-R</option> options.  Note that spoofed-IP attacks
789
	will circumvent the <option>-C</option> option to 
790
	will circumvent the <option>-C</option> option to 
Lines 822-829 Link Here
822
      <para>It is a very good idea to protect internal services from
823
      <para>It is a very good idea to protect internal services from
823
	external access by firewalling them off at your border routers.
824
	external access by firewalling them off at your border routers.
824
	The idea here is to prevent saturation attacks from outside your
825
	The idea here is to prevent saturation attacks from outside your
825
	LAN, not so much to protect internal services from network-based
826
	<acronym>LAN</acronym>, not so much to protect internal services from
826
	<username>root</username> compromise.
827
	network-based <username>root</username> compromise.
827
	Always configure an exclusive firewall, i.e.,
828
	Always configure an exclusive firewall, i.e.,
828
	<quote>firewall everything <emphasis>except</emphasis> ports A, B,
829
	<quote>firewall everything <emphasis>except</emphasis> ports A, B,
829
	C, D, and M-Z</quote>.  This way you can firewall off all of your
830
	C, D, and M-Z</quote>.  This way you can firewall off all of your
Lines 840-846 Link Here
840
	without compromising your low ports.  Also take note that &os;
841
	without compromising your low ports.  Also take note that &os;
841
	allows you to control the range of port numbers used for dynamic
842
	allows you to control the range of port numbers used for dynamic
842
	binding, via the various <varname>net.inet.ip.portrange</varname>
843
	binding, via the various <varname>net.inet.ip.portrange</varname>
843
	<command>sysctl</command>'s (<command>sysctl -a | fgrep
844
	<command>sysctl</command>s (<command>sysctl -a | fgrep
844
	portrange</command>), which can also ease the complexity of your
845
	portrange</command>), which can also ease the complexity of your
845
	firewall's configuration.  For example, you might use a normal
846
	firewall's configuration.  For example, you might use a normal
846
	first/last range of 4000 to 5000, and a hiport range of 49152 to
847
	first/last range of 4000 to 5000, and a hiport range of 49152 to
Lines 848-856 Link Here
848
	(except for certain specific Internet-accessible ports, of
849
	(except for certain specific Internet-accessible ports, of
849
	course).</para>
850
	course).</para>
850
851
851
      <para>Another common DoS attack is called a springboard attack
852
      <para>Another common <acronym>DoS</acronym> attack is called a 
852
	&mdash; to attack a server in a manner that causes the server to
853
        springboard attack &mdash; to attack a server in a manner that causes
853
	generate responses which overloads the server, the local
854
	the server to generate responses which overloads the server, the local
854
	network, or some other machine.  The most common attack of this
855
	network, or some other machine.  The most common attack of this
855
	nature is the <emphasis>ICMP ping broadcast attack</emphasis>.
856
	nature is the <emphasis>ICMP ping broadcast attack</emphasis>.
856
	The attacker spoofs ping packets sent to your LAN's broadcast
857
	The attacker spoofs ping packets sent to your LAN's broadcast
Lines 862-874 Link Here
862
	trick on several dozen broadcast addresses over several dozen
863
	trick on several dozen broadcast addresses over several dozen
863
	different networks at once.  Broadcast attacks of over a hundred
864
	different networks at once.  Broadcast attacks of over a hundred
864
	and twenty megabits have been measured.  A second common
865
	and twenty megabits have been measured.  A second common
865
	springboard attack is against the ICMP error reporting system.
866
	springboard attack is against the
866
	By constructing packets that generate ICMP error responses, an
867
	<acronym role="Internet Control Message Protocol">ICMP</acronym> error
867
	attacker can saturate a server's incoming network and cause the
868
	reporting system. By constructing packets that generate
868
	server to saturate its outgoing network with ICMP responses.  This
869
	<acronym>ICMP</acronym> error responses, an attacker can saturate a
869
	type of attack can also crash the server by running it out of
870
	server's incoming network and cause the server to saturate its outgoing
870
	memory, especially if the server cannot drain the ICMP responses
871
	network with ICMP responses. This type of attack can also crash the
871
	it generates fast enough.
872
	server by running it out of memory, especially if the server cannot
873
	drain the ICMP responses it generates fast enough.
872
	Use the <application>sysctl</application>
874
	Use the <application>sysctl</application>
873
	variable <literal>net.inet.icmp.icmplim</literal> to limit these attacks.
875
	variable <literal>net.inet.icmp.icmplim</literal> to limit these attacks.
874
	The last major class of springboard
876
	The last major class of springboard
Lines 889-900 Link Here
889
	route cache.  Refer to the <varname>net.inet.ip.rtexpire</varname>,
891
	route cache.  Refer to the <varname>net.inet.ip.rtexpire</varname>,
890
	<varname>rtminexpire</varname>, and <varname>rtmaxcache</varname>
892
	<varname>rtminexpire</varname>, and <varname>rtmaxcache</varname>
891
	<command>sysctl</command> parameters.  A spoofed packet attack
893
	<command>sysctl</command> parameters.  A spoofed packet attack
892
	that uses a random source IP will cause the kernel to generate a
894
	that uses a random source IP address will cause the kernel to generate
893
	temporary cached route in the route table, viewable with
895
	a temporary cached route in the route table, viewable with
894
	<command>netstat -rna | fgrep W3</command>.  These routes
896
	<command>netstat -rna | fgrep W3</command>.  These routes
895
	typically timeout in 1600 seconds or so.  If the kernel detects
897
	typically timeout in 1600 seconds or so.  If the kernel detects
896
	that the cached route table has gotten too big it will dynamically
898
	that the cached route table has gotten too big it will dynamically
897
	reduce the <varname>rtexpire</varname> but will never decrease it 
899
	reduce the <varname>rtexpire</varname> but will never decrease it
898
	to less than <varname>rtminexpire</varname>.  There are two 
900
	to less than <varname>rtminexpire</varname>.  There are two 
899
	problems:</para>
901
	problems:</para>
900
	
902
	
Lines 925-941 Link Here
925
      <indexterm><primary>KerberosIV</primary></indexterm>
927
      <indexterm><primary>KerberosIV</primary></indexterm>
926
928
927
      <para>There are a few issues with both Kerberos and
929
      <para>There are a few issues with both Kerberos and
928
	ssh that need to be addressed if
930
	SSH that need to be addressed if
929
	you intend to use them.  Kerberos 5 is an excellent
931
	you intend to use them.  Kerberos 5 is an excellent
930
	authentication protocol, but there are bugs in the kerberized
932
	authentication protocol, but there are bugs in the kerberized
931
	<application>telnet</application> and
933
	<application>telnet</application> and
932
	<application>rlogin</application> applications that make them
934
	<application>rlogin</application> applications that make them
933
	unsuitable for dealing with binary streams.  Also, by default
935
	unsuitable for dealing with binary streams.  Also, by default
934
	Kerberos does not encrypt a session unless you use the
936
	Kerberos does not encrypt a session unless you use the
935
	<option>-x</option> option.  <application>ssh</application>
937
	<option>-x</option> option.  SSH encrypts everything by default.</para>
936
	encrypts everything by default.</para>
937
938
938
      <para>Ssh works quite well in every
939
      <para>SSH works quite well in every
939
	respect except that it forwards encryption keys by default.  What
940
	respect except that it forwards encryption keys by default.  What
940
	this means is that if you have a secure workstation holding keys
941
	this means is that if you have a secure workstation holding keys
941
	that give you access to the rest of the system, and you
942
	that give you access to the rest of the system, and you
Lines 948-964 Link Here
948
	access to any other machine that your keys unlock.</para>
949
	access to any other machine that your keys unlock.</para>
949
950
950
      <para>We recommend that you use ssh in
951
      <para>We recommend that you use ssh in
951
	combination with Kerberos whenever possible for staff logins.
952
	combination with Kerberos whenever possible for staff logins.  The
952
	<application>Ssh</application> can be compiled with Kerberos
953
	<application>ssh</application> client and server can be compiled with
953
	support.  This reduces your reliance on potentially exposed
954
	Kerberos support.  This reduces your reliance on potentially exposed
954
	ssh keys while at the same time
955
	SSH keys while at the same time protecting passwords via Kerberos.
955
	protecting passwords via Kerberos.  Ssh
956
	SSH keys should only be used for automated tasks from secure machines
956
	keys should only be used for automated tasks from secure machines
957
	(something that Kerberos is unsuited to do).  We also recommend that
957
	(something that Kerberos is unsuited to do).  We also recommend that
958
	you either turn off key-forwarding in the
958
	you either turn off key-forwarding in the
959
	ssh configuration, or that you make use
959
	<application>ssh</application> configuration, or that you make use
960
	of the <literal>from=IP/DOMAIN</literal> option that
960
	of the <literal>from=IP/DOMAIN</literal> option that
961
	ssh allows in its
961
	<application>ssh</application> allows in its
962
	<filename>authorized_keys</filename> file to make the key only
962
	<filename>authorized_keys</filename> file to make the key only
963
	usable to entities logging in from specific machines.</para>
963
	usable to entities logging in from specific machines.</para>
964
    </sect2>
964
    </sect2>
Lines 1000-1047 Link Here
1000
      space of possible passwords.</para>
1000
      space of possible passwords.</para>
1001
1001
1002
    <para>Unfortunately the only secure way to encrypt passwords when
1002
    <para>Unfortunately the only secure way to encrypt passwords when
1003
      &unix; came into being was based on DES, the Data Encryption
1003
      &unix; came into being was based on
1004
      Standard.  This was not such a problem for users resident in
1004
      <acronym role="Data Encryption Standard">DES</acronym>, the Data
1005
      the US, but since the source code for DES could not be exported
1005
      Encryption Standard.  This was not such a problem for users resident in
1006
      outside the US, &os; had to find a way to both comply with 
1006
      the US, but since the source code for <acronym>DES</acronym> could not be 
1007
      exported outside the US, &os; had to find a way to both comply with 
1007
      US law and retain compatibility with all the other &unix;
1008
      US law and retain compatibility with all the other &unix;
1008
      variants that still used DES.</para>
1009
      variants that still used <acronym>DES</acronym>.</para>
1009
1010
1010
    <para>The solution was to divide up the encryption libraries 
1011
    <para>The solution was to divide up the encryption libraries 
1011
      so that US users could install the DES libraries and use
1012
      so that US users could install the <acronym>DES</acronym> libraries and
1012
      DES but international users still had an encryption method
1013
      use <acronym>DES</acronym> but international users still had an
1013
      that could be exported abroad.  This is how &os; came to
1014
      encryption method that could be exported abroad.  This is how &os; came
1014
      use MD5 as its default encryption method.  MD5 is believed to
1015
      to use <acronym role="Message Digest 5">MD5</acronym> as its default
1015
      be more secure than DES, so installing DES is offered primarily
1016
      encryption method.  <acronym>MD5</acronym> is believed to be more secure
1016
      for compatibility reasons.</para>
1017
      than <acronym>DES</acronym>, so installing <acronym>DES</acronym> is
1018
      offered primarily for compatibility reasons.</para>
1017
1019
1018
    <sect2>
1020
    <sect2>
1019
      <title>Recognizing Your Crypt Mechanism</title>
1021
      <title>Recognizing Your Crypt Mechanism</title>
1020
1022
1021
      <para>Currently the library supports DES, MD5 and Blowfish hash
1023
      <para>Currently the library supports <acronym>DES</acronym>,
1022
	functions.  By default &os; uses MD5 to encrypt
1024
      <acronym>MD5</acronym> and Blowfish hash
1025
	functions.  By default &os; uses <acronym>MD5</acronym> to encrypt
1023
	passwords.</para>
1026
	passwords.</para>
1024
1027
1025
      <para>It is pretty easy to identify which encryption method 
1028
      <para>It is pretty easy to identify which encryption method 
1026
	&os; is set up to use.  Examining the encrypted passwords in
1029
	&os; is set up to use.  Examining the encrypted passwords in
1027
	the <filename>/etc/master.passwd</filename> file is one way.
1030
	the <filename>/etc/master.passwd</filename> file is one way.
1028
	Passwords encrypted with the MD5 hash are longer than those
1031
	Passwords encrypted with the <acronym>MD5</acronym> hash are longer
1029
	encrypted with the DES hash and also begin with the characters
1032
	than those encrypted with the <acronym>DES</acronym> hash and also
1030
	<literal>&dollar;1&dollar;</literal>.  Passwords starting with
1033
	begin with the characters <literal>&dollar;1&dollar;</literal>.  
1031
	<literal>&dollar;2a&dollar;</literal> are encrypted with the
1034
	Passwords starting with <literal>&dollar;2a&dollar;</literal> are
1032
	Blowfish hash function.  DES password strings do not
1035
	encrypted with the Blowfish hash function.  <acronym>DES</acronym>
1033
	have any particular identifying characteristics, but they are
1036
	password strings do not have any particular identifying characteristics,
1034
	shorter than MD5 passwords, and are coded in a 64-character
1037
	but they are shorter than <acronym>MD5</acronym> passwords, and are
1035
	alphabet which does not include the <literal>&dollar;</literal>
1038
	coded in a 64-character alphabet which does not include the
1036
	character, so a relatively short string which does not begin with
1039
	<literal>&dollar;</literal> character, so a relatively short string
1037
	a dollar sign is very likely a DES password.</para>
1040
	which does not begin with a dollar sign is very likely a
1041
	<acronym>DES</acronym> password.</para>
1038
1042
1039
      <para>The password format used for new passwords is controlled
1043
      <para>The password format used for new passwords is controlled
1040
	by the <literal>passwd_format</literal> login capability in
1044
	by the <literal>passwd_format</literal> login capability in
1041
	<filename>/etc/login.conf</filename>, which takes values of
1045
	<filename>/etc/login.conf</filename>, which takes values of
1042
	<literal>des</literal>, <literal>md5</literal> or
1046
	<literal>des</literal>, <literal>md5</literal> or
1043
	<literal>blf</literal>.  See the &man.login.conf.5; manual page
1047
	<literal>blf</literal>.  See the &man.login.conf.5; manual page
1044
	for more information about login capabilities.</para>
1048
	for more information on login capabilities.</para>
1045
1049
1046
    </sect2>
1050
    </sect2>
1047
  </sect1>
1051
  </sect1>
Lines 1054-1069 Link Here
1054
      <secondary>one-time passwords</secondary>
1058
      <secondary>one-time passwords</secondary>
1055
    </indexterm>
1059
    </indexterm>
1056
1060
1057
    <para>By default, &os; includes support for OPIE (One-time Passwords
1061
    <para>By default, &os; includes support for
1058
      In Everything), which uses the MD5 hash by default.</para>
1062
      <acronym role="One-Time Passwords In Everything">OPIE</acronym>
1063
      (One-time Passwords In Everything), which uses the
1064
      <acronym>MD5</acronym> hash by default.</para>
1059
1065
1060
    <para>There are three different sorts of passwords which we will discuss
1066
    <para>There are three different sorts of passwords which we will discuss
1061
      below.  The first is your usual &unix; style or
1067
      below.  The first is your usual &unix; style or
1062
      Kerberos password; we will call this a <quote>&unix; password</quote>.
1068
      Kerberos password; we will call this a <quote>&unix; password</quote>.
1063
      The second sort is the one-time password which is generated by the OPIE
1069
      The second sort is the one-time password which is generated by the 
1064
      &man.opiekey.1; program and accepted by the
1070
      <acronym>OPIE</acronym> &man.opiekey.1; program and accepted by the
1065
      &man.opiepasswd.1; program
1071
      &man.opiepasswd.1; program and the login prompt; we will
1066
      and the login prompt; we will
1067
      call this a <quote>one-time password</quote>.  The final sort of
1072
      call this a <quote>one-time password</quote>.  The final sort of
1068
      password is the secret password which you give to the
1073
      password is the secret password which you give to the
1069
      <command>opiekey</command> program (and
1074
      <command>opiekey</command> program (and
Lines 1075-1106 Link Here
1075
1080
1076
    <para>The secret password does not have anything to do with your &unix;
1081
    <para>The secret password does not have anything to do with your &unix;
1077
      password; they can be the same but this is not recommended.
1082
      password; they can be the same but this is not recommended.
1078
      OPIE secret passwords are not limited to 8 characters like old
1083
      <acronym>OPIE</acronym> secret passwords are not limited to 8 characters
1079
      &unix; passwords<footnote><para>Under &os; the standard login
1084
      like old &unix; passwords<footnote><para>Under &os; the standard login
1080
      password may be up to 128 characters in length.</para></footnote>,
1085
      password may be up to 128 characters in length.</para></footnote>,
1081
      they can be as long as you like.  Passwords of six or
1086
      they can be as long as you like.  Passwords of six or
1082
      seven word long phrases are fairly common.  For the most part, the
1087
      seven word long phrases are fairly common.  For the most part, the
1083
      OPIE system operates completely independently of the &unix;
1088
      <acronym>OPIE</acronym> system operates completely independently of the
1084
      password system.</para>
1089
      &unix; password system.</para>
1085
1090
1086
    <para>Besides the password, there are two other pieces of data that
1091
    <para>Besides the password, there are two other pieces of data that
1087
      are important to OPIE.  One is what is known as the
1092
      are important to <acronym>OPIE</acronym>.  One is what is known as the
1088
      <quote>seed</quote> or <quote>key</quote>, consisting of two letters
1093
      <quote>seed</quote> or <quote>key</quote>, consisting of two letters
1089
      and five digits.  The other is what is called the <quote>iteration
1094
      and five digits.  The other is what is called the <quote>iteration
1090
      count</quote>, a number between 1 and 100.  OPIE creates the
1095
      count</quote>, a number between 1 and 100.  <acronym>OPIE</acronym> 
1091
      one-time password by concatenating the seed and the secret password,
1096
      creates the one-time password by concatenating the seed and the secret 
1092
      then applying the MD5 hash as many times as specified by the
1097
      password, then applying the <acronym>MD5</acronym> hash as many times as
1093
      iteration count and turning the result into six short English words.
1098
      specified by the iteration count and turning the result into six short 
1094
      These six English words are your one-time password.  The
1099
      English words. These six English words are your one-time password.  The
1095
      authentication system (primarily PAM) keeps
1100
      authentication system (primarily 
1096
      track of the last one-time password used, and the user is
1101
      <acronym role="Pluggable Authentication Modules">PAM</acronym>)
1102
      keeps track of the last one-time password used, and the user is
1097
      authenticated if the hash of the user-provided password is equal to
1103
      authenticated if the hash of the user-provided password is equal to
1098
      the previous password.  Because a one-way hash is used it is
1104
      the previous password.  Because a one-way hash is used it is
1099
      impossible to generate future one-time passwords if a successfully
1105
      impossible to generate future one-time passwords if a successfully
1100
      used password is captured; the iteration count is decremented after
1106
      used password is captured; the iteration count is decremented after
1101
      each successful login to keep the user and the login program in
1107
      each successful login to keep the user and the login program in
1102
      sync.  When the iteration count gets down to 1, OPIE must be
1108
      sync.  When the iteration count gets down to 1, <acronym>OPIE</acronym>
1103
      reinitialized.</para>
1109
      must be reinitialized.</para>
1104
1110
1105
    <para>There are a few programs involved in each system
1111
    <para>There are a few programs involved in each system
1106
      which we will discuss below.  The
1112
      which we will discuss below.  The
Lines 1108-1114 Link Here
1108
      count, a seed, and a secret password, and generates a one-time
1114
      count, a seed, and a secret password, and generates a one-time
1109
      password or a consecutive list of one-time passwords.  The
1115
      password or a consecutive list of one-time passwords.  The
1110
      <command>opiepasswd</command>
1116
      <command>opiepasswd</command>
1111
      program is used to initialize OPIE,
1117
      program is used to initialize <acronym>OPIE</acronym>,
1112
      and to change passwords, iteration counts, or seeds; it
1118
      and to change passwords, iteration counts, or seeds; it
1113
      takes either a secret passphrase, or an iteration count,
1119
      takes either a secret passphrase, or an iteration count,
1114
      seed, and a one-time password.  The
1120
      seed, and a one-time password.  The
Lines 1133-1140 Link Here
1133
1139
1134
    <sect2>
1140
    <sect2>
1135
      <title>Secure Connection Initialization</title>
1141
      <title>Secure Connection Initialization</title>
1136
      <para>To initialize OPIE for the first time, execute the
1142
      <para>To initialize <acronym>OPIE</acronym> for the first time, execute
1137
        <command>opiepasswd</command> command:</para>
1143
        the <command>opiepasswd</command> command:</para>
1138
1144
1139
      <screen>&prompt.user; <userinput>opiepasswd -c</userinput>
1145
      <screen>&prompt.user; <userinput>opiepasswd -c</userinput>
1140
[grimreaper] ~ $ opiepasswd -f -c
1146
[grimreaper] ~ $ opiepasswd -f -c
Lines 1210-1216 Link Here
1210
    <sect2>
1216
    <sect2>
1211
      <title>Generating a Single One-time Password</title>
1217
      <title>Generating a Single One-time Password</title>
1212
1218
1213
      <para>Once you have initialized OPIE and login, you will be 
1219
      <para>Once you have initialized OPIE and login, you will be
1214
	presented with a prompt like this:</para>
1220
	presented with a prompt like this:</para>
1215
1221
1216
<screen>&prompt.user; <userinput>telnet example.com</userinput>
1222
<screen>&prompt.user; <userinput>telnet example.com</userinput>
Lines 1224-1231 Link Here
1224
otp-md5 498 gr4269 ext
1230
otp-md5 498 gr4269 ext
1225
Password: </screen>
1231
Password: </screen>
1226
1232
1227
      <para>As a side note, the OPIE prompts have a useful feature
1233
      <para>As a side note, the <acronym>OPIE</acronym> prompts have a useful
1228
	(not shown here): if you press <keycap>Return</keycap>
1234
        feature (not shown here): if you press <keycap>Return</keycap>
1229
	at the password prompt, the
1235
	at the password prompt, the
1230
	prompter will turn echo on, so you can see what you are
1236
	prompter will turn echo on, so you can see what you are
1231
	typing.  This can be extremely useful if you are attempting to
1237
	typing.  This can be extremely useful if you are attempting to
Lines 1290-1297 Link Here
1290
    <sect2>
1296
    <sect2>
1291
      <title>Restricting Use of &unix; Passwords</title>
1297
      <title>Restricting Use of &unix; Passwords</title>
1292
1298
1293
      <para>OPIE can restrict the use of &unix; passwords based on the IP
1299
      <para><acronym>OPIE</acronym> can restrict the use of &unix; passwords
1294
	address of a login session.  The relevant file
1300
        based on the IP address of a login session.  The relevant file
1295
	is <filename>/etc/opieaccess</filename>, which is present by default.
1301
	is <filename>/etc/opieaccess</filename>, which is present by default.
1296
	Please check &man.opieaccess.5;
1302
	Please check &man.opieaccess.5;
1297
	for more information on this file and which security considerations
1303
	for more information on this file and which security considerations
Lines 1327-1333 Link Here
1327
    <title>TCP Wrappers</title>
1333
    <title>TCP Wrappers</title>
1328
1334
1329
    <para>Anyone familiar with &man.inetd.8; has probably heard
1335
    <para>Anyone familiar with &man.inetd.8; has probably heard
1330
      of <acronym>TCP</acronym> Wrappers at some point.  But few
1336
      of <acronym role="Transport Control Protocol">TCP</acronym>
1337
      Wrappers at some point.  But few
1331
      individuals seem to fully comprehend its usefulness in a
1338
      individuals seem to fully comprehend its usefulness in a
1332
      network environment.  It seems that everyone wants to
1339
      network environment.  It seems that everyone wants to
1333
      install a firewall to handle network connections.  While a
1340
      install a firewall to handle network connections.  While a
Lines 1591-1598 Link Here
1591
        during the era of restrictive export controls on cryptographic
1598
        during the era of restrictive export controls on cryptographic
1592
        code from the USA.</para>
1599
        code from the USA.</para>
1593
1600
1594
      <para>Alternatively, the MIT implementation of Kerberos is
1601
      <para>Alternatively, the 
1595
        available from the Ports Collection as
1602
        <acronym role="Massachusetts Insitute of Technology">MIT</acronym>
1603
	implementation of Kerberos is available from the Ports Collection as
1596
        <filename role="package">security/krb5</filename>.</para>
1604
        <filename role="package">security/krb5</filename>.</para>
1597
    </sect2>
1605
    </sect2>
1598
1606
Lines 1889-1895 Link Here
1889
Apr 30 11:23:22  Apr 30 19:23:22  krbtgt.EXAMPLE.COM@EXAMPLE.COM</screen>
1897
Apr 30 11:23:22  Apr 30 19:23:22  krbtgt.EXAMPLE.COM@EXAMPLE.COM</screen>
1890
1898
1891
      <para>Now try changing the password using &man.passwd.1; to
1899
      <para>Now try changing the password using &man.passwd.1; to
1892
	check if the <application>kpasswd</application> daemon can get 
1900
	check if the <application>kpasswd</application> daemon can get
1893
	authorization to the Kerberos database:</para>
1901
	authorization to the Kerberos database:</para>
1894
1902
1895
      <screen>&prompt.user; <userinput>passwd</userinput>
1903
      <screen>&prompt.user; <userinput>passwd</userinput>
Lines 2133-2139 Link Here
2133
	programs that implement the program
2141
	programs that implement the program
2134
	(<application>Kerberos</application> telnet, for example).  The
2142
	(<application>Kerberos</application> telnet, for example).  The
2135
	current version of the protocol is version 5, described in
2143
	current version of the protocol is version 5, described in
2136
	<acronym>RFC</acronym>&nbsp;1510.</para>
2144
	<acronym role="Request For Comments">RFC</acronym>&nbsp;1510.</para>
2137
2145
2138
      <para>Several free implementations of this protocol are available,
2146
      <para>Several free implementations of this protocol are available,
2139
	covering a wide range of operating systems.  The Massachusetts
2147
	covering a wide range of operating systems.  The Massachusetts
Lines 2168-2174 Link Here
2168
	<secondary>Key Distribution Center</secondary>
2176
	<secondary>Key Distribution Center</secondary>
2169
      </indexterm>
2177
      </indexterm>
2170
2178
2171
      <para>The Key Distribution Center (<acronym>KDC</acronym>) is the
2179
      <para>The Key Distribution Center 
2180
        <acronym role="Key Distribution Center">KDC</acronym>) is the
2172
	centralized authentication service that
2181
	centralized authentication service that
2173
	<application>Kerberos</application> provides &mdash; it is the
2182
	<application>Kerberos</application> provides &mdash; it is the
2174
	computer that issues <application>Kerberos</application> tickets.
2183
	computer that issues <application>Kerberos</application> tickets.
Lines 2580-2587 Link Here
2580
	      immediately upon running <command>kinit</command> &mdash;
2589
	      immediately upon running <command>kinit</command> &mdash;
2581
	      even before you type your password!  The explanation is
2590
	      even before you type your password!  The explanation is
2582
	      that the <application>Kerberos</application> server freely
2591
	      that the <application>Kerberos</application> server freely
2583
	      transmits a <acronym>TGT</acronym> (Ticket Granting
2592
	      transmits a
2584
	      Ticket) to any unauthorized request;  however, every
2593
	      <acronym role="Ticket Granting Ticket">TGT</acronym> (Ticket
2594
	      Granting Ticket) to any unauthorized request;  however, every
2585
	      <acronym>TGT</acronym> is encrypted in a key derived from
2595
	      <acronym>TGT</acronym> is encrypted in a key derived from
2586
	      the user's password.  Therefore, when a user types their
2596
	      the user's password.  Therefore, when a user types their
2587
	      password it is not being sent to the <acronym>KDC</acronym>,
2597
	      password it is not being sent to the <acronym>KDC</acronym>,
Lines 2726-2732 Link Here
2726
	</sect3>
2736
	</sect3>
2727
2737
2728
	<sect3>
2738
	<sect3>
2729
	  <title>The KDC is a single point of failure</title>
2739
	  <title>The <acronym>KDC</acronym> is a single point of failure</title>
2730
2740
2731
	  <para>By design, the <acronym>KDC</acronym> must be as secure as
2741
	  <para>By design, the <acronym>KDC</acronym> must be as secure as
2732
	    the master password database is contained on it.  The
2742
	    the master password database is contained on it.  The
Lines 2783-2789 Link Here
2783
	  <listitem>
2793
	  <listitem>
2784
	  <para><ulink
2794
	  <para><ulink
2785
	    url="http://www.faqs.org/faqs/Kerberos-faq/general/preamble.html">
2795
	    url="http://www.faqs.org/faqs/Kerberos-faq/general/preamble.html">
2786
	    The <application>Kerberos</application> FAQ</ulink></para>
2796
	    The <application>Kerberos</application> <acronym>FAQ</acronym>
2797
	    </ulink></para>
2787
	</listitem>
2798
	</listitem>
2788
2799
2789
	<listitem>
2800
	<listitem>
Lines 2792-2800 Link Here
2792
	</listitem>
2803
	</listitem>
2793
2804
2794
	<listitem>
2805
	<listitem>
2795
	  <para><ulink url="http://www.ietf.org/rfc/rfc1510.txt?number=1510">RFC 1510,
2806
	  <para><ulink
2796
	    The <application>Kerberos</application> Network Authentication Service
2807
	  url="http://www.ietf.org/rfc/rfc1510.txt?number=1510">
2797
	    (V5)</ulink></para>
2808
	    <acronym>RFC</acronym> 1510, The <application>Kerberos</application>
2809
	    Network Authentication Service (V5)</ulink></para>
2798
	</listitem>
2810
	</listitem>
2799
2811
2800
	<listitem>
2812
	<listitem>
Lines 2850-2858 Link Here
2850
    </note>
2862
    </note>
2851
2863
2852
    <para>The version of <application>OpenSSL</application> included
2864
    <para>The version of <application>OpenSSL</application> included
2853
      in &os; supports Secure Sockets Layer v2/v3 (SSLv2/SSLv3),
2865
      in &os; supports Secure Sockets Layer v2/v3 (
2854
      Transport Layer Security v1 (TLSv1) network security protocols
2866
      <acronym role="Secure Sockets Layer">SSL</acronym>v2/
2855
      and can be used as a general cryptographic library.</para>
2867
      <acronym>SSL</acronym>v3), Transport Layer Security v1 
2868
      (<acronym role="Transport Layer Security">TLS</acronym>v1) network 
2869
      security protocols and can be used as a general cryptographic library.
2870
      </para>
2856
2871
2857
    <note>
2872
    <note>
2858
      <para>While <application>OpenSSL</application> supports the
2873
      <para>While <application>OpenSSL</application> supports the
Lines 2869-2876 Link Here
2869
      that the credentials of the company or individual are valid
2884
      that the credentials of the company or individual are valid
2870
      and not fraudulent.  If the certificate in question has
2885
      and not fraudulent.  If the certificate in question has
2871
      not been verified by one of the several <quote>Certificate Authorities</quote>,
2886
      not been verified by one of the several <quote>Certificate Authorities</quote>,
2872
      or <acronym>CA</acronym>s, a warning is usually produced.  A
2887
      or <acronym role="Certificate Authorities">CA</acronym>s, a warning is
2873
      Certificate Authority is a company, such as <ulink url="http://www.verisign.com">VeriSign</ulink>, which will
2888
      usually produced.  A Certificate Authority is a company, such as
2889
      <ulink url="http://www.verisign.com">VeriSign</ulink>, which will
2874
      sign certificates in order to validate credentials of individuals
2890
      sign certificates in order to validate credentials of individuals
2875
      or companies.  This process has a cost associated with it and
2891
      or companies.  This process has a cost associated with it and
2876
      is definitely not a requirement for using certificates; however,
2892
      is definitely not a requirement for using certificates; however,
Lines 2961-2969 Link Here
2961
2977
2962
      <para>So what can these files do?  A good use would be to
2978
      <para>So what can these files do?  A good use would be to
2963
	encrypt connections to the <application>Sendmail</application>
2979
	encrypt connections to the <application>Sendmail</application>
2964
	<acronym>MTA</acronym>.  This would dissolve the use of clear
2980
	<acronym role="Mail Transport Agent">MTA</acronym>.  This would
2965
	text authentication for users who send mail via the local
2981
	dissolve the use of clear text authentication for users who send
2966
	<acronym>MTA</acronym>.</para>
2982
	mail via the local <acronym>MTA</acronym>.</para>
2967
2983
2968
      <note>
2984
      <note>
2969
	<para>This is not the best use in the world as some
2985
	<para>This is not the best use in the world as some
Lines 3047-3053 Link Here
3047
    </indexterm>
3063
    </indexterm>
3048
3064
3049
    <title>VPN over IPsec</title>
3065
    <title>VPN over IPsec</title>
3050
    <para>Creating a VPN between two networks, separated by the
3066
    <para>Creating a <acronym role="Virtual Private Network">VPN</acronym>
3067
      between two networks, separated by the
3051
      Internet, using FreeBSD gateways.</para>
3068
      Internet, using FreeBSD gateways.</para>
3052
 
3069
 
3053
    <sect2>
3070
    <sect2>
Lines 3067-3096 Link Here
3067
      <title>Understanding IPsec</title>
3084
      <title>Understanding IPsec</title>
3068
3085
3069
      <para>This section will guide you through the process of setting
3086
      <para>This section will guide you through the process of setting
3070
	up IPsec, and to use it in an environment which consists of
3087
	up <acronym role="IP Security">IPsec</acronym>, and to use it in an
3088
	environment which consists of
3071
	FreeBSD and <application>&microsoft.windows; 2000/XP</application>
3089
	FreeBSD and <application>&microsoft.windows; 2000/XP</application>
3072
	machines, to make them communicate securely.  In order to set up
3090
	machines, to make them communicate securely.  In order to set up
3073
	IPsec, it is necessary that you are familiar with the concepts
3091
	<acronym>IPsec</acronym>, it is necessary that you are familiar with
3074
	of building a custom kernel (see
3092
	the concepts of building a custom kernel (see
3075
	<xref linkend="kernelconfig">).</para>
3093
	<xref linkend="kernelconfig">).</para>
3076
    
3094
    
3077
      <para><emphasis>IPsec</emphasis> is a protocol which sits on top
3095
      <para><emphasis>IPsec</emphasis> is a protocol which sits on top
3078
	of the Internet Protocol (IP) layer.  It allows two or more
3096
	of the Internet Protocol 
3079
	hosts to communicate in a secure manner (hence the name).  The
3097
	(<acronym role="Internet Protocol"IP</acronym>) layer.  It allows two
3080
	FreeBSD IPsec <quote>network stack</quote> is based on the
3098
	or more hosts to communicate in a secure manner (hence the name).  The
3081
	<ulink url="http://www.kame.net/">KAME</ulink> implementation,
3099
	FreeBSD <acronym>IPsec</acronym> <quote>network stack</quote> is based
3082
	which has support for both protocol families, IPv4 and
3100
	on the <ulink url="http://www.kame.net/">KAME</ulink> implementation,
3083
	IPv6.</para>
3101
	which has support for both protocol families, IPv4 and IPv6.</para>
3084
3102
3085
      <note>
3103
      <note>
3086
        <para>FreeBSD contains a <quote>hardware
3104
        <para>FreeBSD contains a <quote>hardware
3087
        accelerated</quote> IPsec stack, known as <quote>Fast
3105
        accelerated</quote> <acroonym>IPsec</acronym> stack, known as
3088
        IPsec</quote>, that was obtained from OpenBSD.  It employs
3106
	<quote>Fast IPsec</quote>, that was obtained from OpenBSD.  It employs
3089
        cryptographic hardware (whenever possible) via the
3107
        cryptographic hardware (whenever possible) via the
3090
        &man.crypto.4; subsystem to optimize the performance of IPsec.
3108
        &man.crypto.4; subsystem to optimize the performance of
3109
	<acronym>IPsec.</acronym>
3091
        This subsystem is new, and does not support all the features
3110
        This subsystem is new, and does not support all the features
3092
        that are available in the KAME version of IPsec.  However, in
3111
        that are available in the KAME version of <acronym>IPsec</acronym>.
3093
        order to enable hardware-accelerated IPsec, the following
3112
	However, in order to enable hardware-accelerated
3113
	<acronym>IPsec</acronym>, the following
3094
        kernel option has to be added to your kernel configuration
3114
        kernel option has to be added to your kernel configuration
3095
        file:</para>
3115
        file:</para>
3096
3116
Lines 3105-3112 Link Here
3105
3125
3106
        <para> Note, that it is not currently possible to use the
3126
        <para> Note, that it is not currently possible to use the
3107
	  <quote>Fast IPsec</quote> subsystem in lieu of the KAME
3127
	  <quote>Fast IPsec</quote> subsystem in lieu of the KAME
3108
	  implementation of IPsec.  Consult the &man.fast.ipsec.4;
3128
	  implementation of <acronym>IPsec</acronym>.  Consult the
3109
	  manual page for more information.</para>
3129
	  &man.fast.ipsec.4; manual page for more information.</para>
3110
      </note>
3130
      </note>
3111
3131
3112
      <note>
3132
      <note>
Lines 3130-3152 Link Here
3130
	<secondary>AH</secondary>
3150
	<secondary>AH</secondary>
3131
      </indexterm>
3151
      </indexterm>
3132
3152
3133
      <para>IPsec consists of two sub-protocols:</para>
3153
      <para><acronym>IPsec</acronym> consists of two sub-protocols:</para>
3134
3154
3135
      <itemizedlist>
3155
      <itemizedlist>
3136
        <listitem>
3156
        <listitem>
3137
          <para><emphasis>Encapsulated Security Payload
3157
          <para><emphasis>Encapsulated Security Payload
3138
	      (ESP)</emphasis>, protects the IP packet data from third
3158
	    (<acronym role="Encapsulated Security Payload">ESP</acronym>)
3139
	    party interference, by encrypting the contents using
3159
	    </emphasis>, protects the <acronym>IP</acronym> packet data from
3160
	    third party interference, by encrypting the contents using
3140
	    symmetric cryptography algorithms (like Blowfish,
3161
	    symmetric cryptography algorithms (like Blowfish,
3141
	    3DES).</para>
3162
	    <acronym>3DES</acronym>).</para>
3142
        </listitem>
3163
        </listitem>
3143
        <listitem>
3164
        <listitem>
3144
          <para><emphasis>Authentication Header (AH)</emphasis>,
3165
          <para><emphasis>Authentication Header
3145
	    protects the IP packet header from third party interference
3166
	    (<acronym role="Authentication Header">AH</acronym>)</emphasis>,
3146
	    and spoofing, by computing a cryptographic checksum and
3167
	    protects the <acronym>IP</acronym> packet header from third party
3147
	    hashing the IP packet header fields with a secure hashing
3168
	    interference and spoofing, by computing a cryptographic checksum
3148
	    function.  This is then followed by an additional header
3169
	    and hashing the <acronym>IP</acronym> packet header fields with a
3149
	    that contains the hash, to allow the information in the
3170
	    secure hashing function.  This is then followed by an additional
3171
	    header that contains the hash, to allow the information in the
3150
	    packet to be authenticated.</para>
3172
	    packet to be authenticated.</para>
3151
        </listitem>
3173
        </listitem>
3152
      </itemizedlist>
3174
      </itemizedlist>
Lines 3164-3181 Link Here
3164
	<see>VPN</see>
3186
	<see>VPN</see>
3165
      </indexterm>
3187
      </indexterm>
3166
3188
3167
      <para>IPsec can either be used to directly encrypt the traffic
3189
      <para><acronym>IPsec</acronym> can either be used to directly encrypt
3168
	between two hosts (known as <emphasis>Transport
3190
        the traffic between two hosts (known as <emphasis>Transport
3169
	  Mode</emphasis>); or to build <quote>virtual tunnels</quote>
3191
	Mode</emphasis>); or to build <quote>virtual tunnels</quote>
3170
	between two subnets, which could be used for secure
3192
	between two subnets, which could be used for secure
3171
	communication between two corporate networks (known as
3193
	communication between two corporate networks (known as
3172
	<emphasis>Tunnel Mode</emphasis>).  The latter is more commonly
3194
	<emphasis>Tunnel Mode</emphasis>).  The latter is more commonly
3173
	known as a <emphasis>Virtual Private Network (VPN)</emphasis>.
3195
	known as a <emphasis>Virtual Private Network (<acronym>VPN</acronym>)
3174
	The &man.ipsec.4; manual page should be consulted for detailed
3196
	</emphasis>. The &man.ipsec.4; manual page should be consulted for
3175
	information on the IPsec subsystem in FreeBSD.</para>
3197
	detailed information on the <acronym>IPsec</acronym> subsystem in
3198
	&os;.</para>
3176
      
3199
      
3177
      <para>To add IPsec support to your kernel, add the following
3200
      <para>To add <acronym>IPsec</acronym> support to your kernel, add the
3178
	options to your kernel configuration file:</para>
3201
        following options to your kernel configuration file:</para>
3179
3202
3180
      <indexterm>
3203
      <indexterm>
3181
	<primary>kernel options</primary>
3204
	<primary>kernel options</primary>
Lines 3208-3218 Link Here
3208
    <sect2>
3231
    <sect2>
3209
      <title>The Problem</title>
3232
      <title>The Problem</title>
3210
 
3233
 
3211
      <para>There is no standard for what constitutes a VPN.  VPNs can
3234
      <para>There is no standard for what constitutes a <acronym>VPN</acronym>.
3212
	be implemented using a number of different technologies, each of
3235
        <acronym>VPN</acronym>s can be implemented using a number of different
3236
	technologies, each of
3213
	which have their own strengths and weaknesses.  This section
3237
	which have their own strengths and weaknesses.  This section
3214
	presents a scenario, and the strategies used for implementing a
3238
	presents a scenario, and the strategies used for implementing a
3215
	VPN for this scenario.</para>
3239
	<acronym>VPN</acronym> for this scenario.</para>
3216
    </sect2>
3240
    </sect2>
3217
    
3241
    
3218
    <sect2> 
3242
    <sect2> 
Lines 3231-3263 Link Here
3231
          <para>You have at least two sites</para>
3255
          <para>You have at least two sites</para>
3232
        </listitem>
3256
        </listitem>
3233
        <listitem>
3257
        <listitem>
3234
          <para>Both sites are using IP internally</para>
3258
          <para>Both sites are using <acronym>IP</acronym> internally</para>
3235
        </listitem>
3259
        </listitem>
3236
        <listitem>
3260
        <listitem>
3237
          <para>Both sites are connected to the Internet, through a
3261
          <para>Both sites are connected to the Internet, through a
3238
            gateway that is running FreeBSD.</para>
3262
            gateway that is running FreeBSD.</para>
3239
        </listitem>
3263
        </listitem>
3240
        <listitem>
3264
        <listitem>
3241
          <para>The gateway on each network has at least one public IP
3265
          <para>The gateway on each network has at least one public 
3242
            address.</para>
3266
	    <acronym>IP</acronym>address.</para>
3243
        </listitem>
3267
        </listitem>
3244
        <listitem>
3268
        <listitem>
3245
          <para>The internal addresses of the two networks can be
3269
          <para>The internal addresses of the two networks can be
3246
            public or private IP addresses, it does not matter.  You can
3270
            public or private <acronym>IP</acronym> addresses, it does not
3247
            be running NAT on the gateway machine if necessary.</para>
3271
	    matter.  You can be running 
3272
	    <acronym role="Network Address Translation">NAT</acronym> on the
3273
	    gateway machine if necessary.</para>
3248
        </listitem>
3274
        </listitem>
3249
        <listitem>
3275
        <listitem>
3250
          <para>The internal IP addresses of the two networks
3276
          <para>The internal <acronym>IP</acronym> addresses of the two
3251
            <emphasis>do not collide</emphasis>.  While I expect it is
3277
	    networks <emphasis>do not collide</emphasis>.  While I expect it
3252
            theoretically possible to use a combination of VPN
3278
	    is theoretically possible to use a combination of
3253
            technology and NAT to get this to work, I expect it to be a
3279
	    <acronym>VPN</acronym> technology and <acronym>NAT</acronym>
3280
	    to get this to work, I expect it to be a
3254
            configuration nightmare.</para>
3281
            configuration nightmare.</para>
3255
        </listitem>
3282
        </listitem>
3256
      </itemizedlist>
3283
      </itemizedlist>
3257
      
3284
      
3258
      <para>If you find that you are trying to connect two networks,
3285
      <para>If you find that you are trying to connect two networks,
3259
        both of which, internally, use the same private IP address range
3286
        both of which, internally, use the same private <acronym>IP</acronym>
3260
        (e.g. both of them use <hostid
3287
	address range (e.g. both of them use <hostid
3261
        role="ipaddr">192.168.1.x</hostid>), then one of the networks will
3288
        role="ipaddr">192.168.1.x</hostid>), then one of the networks will
3262
        have to be renumbered.</para>
3289
        have to be renumbered.</para>
3263
 
3290
 
Lines 3293-3306 Link Here
3293
	</textobject>
3320
	</textobject>
3294
      </mediaobject>
3321
      </mediaobject>
3295
 
3322
 
3296
      <para>Notice the two public IP addresses.  I will use the letters to
3323
      <para>Notice the two public <acronym>IP</acronym> addresses.  I will use
3324
        the letters to
3297
        refer to them in the rest of this article.  Anywhere you see those
3325
        refer to them in the rest of this article.  Anywhere you see those
3298
        letters in this article, replace them with your own public IP
3326
        letters in this article, replace them with your own public IP
3299
        addresses.  Note also that internally, the two gateway
3327
        addresses.  Note also that internally, the two gateway
3300
        machines have .1 IP addresses, and that the two networks have
3328
        machines have <hostid role="ipaddr">.1</hostid> <acronym>IP</acronym>
3301
        different private IP addresses (<hostid
3329
	addresses, and that the two networks have different private
3302
        role="ipaddr">192.168.1.x</hostid> and <hostid
3330
	<acronym>IP</acronym> addresses  
3303
        role="ipaddr">192.168.2.x</hostid> respectively).  All the
3331
	(<hostid role="ipaddr">192.168.1.x</hostid> and 
3332
	<hostid role="ipaddr">192.168.2.x</hostid> respectively).  All the
3304
        machines on the private networks have been configured to use the
3333
        machines on the private networks have been configured to use the
3305
        <hostid role="ipaddr">.1</hostid> machine as their default
3334
        <hostid role="ipaddr">.1</hostid> machine as their default
3306
        gateway.</para>
3335
        gateway.</para>
Lines 3323-3330 Link Here
3323
      <para>And the whole thing has to be secure.  This means that
3352
      <para>And the whole thing has to be secure.  This means that
3324
        traffic between the two networks has to be encrypted.</para>
3353
        traffic between the two networks has to be encrypted.</para>
3325
 
3354
 
3326
      <para>Creating a VPN between these two networks is a multi-step
3355
      <para>Creating a <acronym>VPN</acronym> between these two networks is a
3327
        process.  The stages are as follows:</para>
3356
        multi-step process.  The stages are as follows:</para>
3328
 
3357
 
3329
      <orderedlist>
3358
      <orderedlist>
3330
        <listitem>
3359
        <listitem>
Lines 3343-3349 Link Here
3343
        <listitem>
3372
        <listitem>
3344
          <para>Configure additional software on the FreeBSD gateways,
3373
          <para>Configure additional software on the FreeBSD gateways,
3345
            to allow &windows; machines to see one another across the
3374
            to allow &windows; machines to see one another across the
3346
            VPN.</para>
3375
            <acronym>VPN</acronym>.</para>
3347
        </listitem>
3376
        </listitem>
3348
      </orderedlist>
3377
      </orderedlist>
3349
3378
Lines 3400-3408 Link Here
3400
        the public IP addresses, and two for the private IP
3429
        the public IP addresses, and two for the private IP
3401
        addresses.</para>
3430
        addresses.</para>
3402
 
3431
 
3403
      <para>Support for the gif device must be compiled in to the
3432
      <para>Support for the <devicename>gif</devicename> device must be
3404
        &os; kernel on both machines.  You can do this by adding the
3433
        compiled in to the &os; kernel on both machines.  You can do this by
3405
        line:</para>
3434
	adding the line:</para>
3406
 
3435
 
3407
      <programlisting>device gif</programlisting>
3436
      <programlisting>device gif</programlisting>
3408
 
3437
 
Lines 3410-3417 Link Here
3410
        then compile, install, and reboot as normal.</para>
3439
        then compile, install, and reboot as normal.</para>
3411
 
3440
 
3412
      <para>Configuring the tunnel is a two step process.  First the
3441
      <para>Configuring the tunnel is a two step process.  First the
3413
        tunnel must be told what the outside (or public) IP addresses
3442
        tunnel must be told what the outside (or public) <acronym>IP</acronym>
3414
        are, using &man.ifconfig.8;.  Then the private IP addresses must be
3443
	addresses are, using &man.ifconfig.8;.  Then the private 
3444
	<acronym>IP</acronym> addresses must be
3415
        configured using &man.ifconfig.8;.</para>
3445
        configured using &man.ifconfig.8;.</para>
3416
 
3446
 
3417
      <para>On the gateway machine on network #1 you would run the
3447
      <para>On the gateway machine on network #1 you would run the
Lines 3423-3429 Link Here
3423
      </screen>
3453
      </screen>
3424
3454
3425
      <para>On the other gateway machine you run the same commands,
3455
      <para>On the other gateway machine you run the same commands,
3426
        but with the order of the IP addresses reversed.</para>
3456
        but with the order of the <acronym>IP</acronym> addresses reversed.
3457
	</para>
3427
3458
3428
      <screen>&prompt.root; <userinput>ifconfig <replaceable>gif0</replaceable> create</userinput>
3459
      <screen>&prompt.root; <userinput>ifconfig <replaceable>gif0</replaceable> create</userinput>
3429
&prompt.root; <userinput>ifconfig <replaceable>gif0</replaceable> tunnel <replaceable>W.X.Y.Z</replaceable> <replaceable>A.B.C.D</replaceable></userinput>
3460
&prompt.root; <userinput>ifconfig <replaceable>gif0</replaceable> tunnel <replaceable>W.X.Y.Z</replaceable> <replaceable>A.B.C.D</replaceable></userinput>
Lines 3471-3485 Link Here
3471
        shortly.</para>
3502
        shortly.</para>
3472
 
3503
 
3473
      <para>It is likely that you are running a firewall on both
3504
      <para>It is likely that you are running a firewall on both
3474
        machines.  This will need to be circumvented for your VPN
3505
        machines.  This will need to be circumvented for your 
3475
        traffic.  You might want to allow all traffic between both
3506
	<acronym>VPN</acronym> traffic.  You might want to allow all traffic
3476
        networks, or you might want to include firewall rules that
3507
	between both networks, or you might want to include firewall rules
3477
        protect both ends of the VPN from one another.</para>
3508
	that protect both ends of the <acronym>VPN</acronym> from one
3509
	another.</para>
3478
 
3510
 
3479
      <para>It greatly simplifies testing if you configure the
3511
      <para>It greatly simplifies testing if you configure the
3480
        firewall to allow all traffic through the VPN.  You can always
3512
        firewall to allow all traffic through the <acronym>VPN</acronym>.
3481
        tighten things up later.  If you are using &man.ipfw.8; on the
3513
	You can always tighten things up later.  If you are using &man.ipfw.8;
3482
        gateway machines then a command like</para>
3514
	on the gateway machines then a command like</para>
3483
3515
3484
      <programlisting>ipfw add 1 allow ip from any to any via gif0</programlisting>
3516
      <programlisting>ipfw add 1 allow ip from any to any via gif0</programlisting>
3485
 
3517
 
Lines 3487-3495 Link Here
3487
        VPN, without affecting your other firewall rules.  Obviously
3519
        VPN, without affecting your other firewall rules.  Obviously
3488
        you will need to run this command on both gateway hosts.</para>
3520
        you will need to run this command on both gateway hosts.</para>
3489
 
3521
 
3490
      <para>This is sufficient to allow each gateway machine to ping
3522
      <para>This is sufficient to allow each gateway machine to
3491
        the other.  On <hostid role="ipaddr">192.168.1.1</hostid>, you
3523
        <command>ping</command> the other.  On
3492
        should be able to run</para>
3524
	<hostid role="ipaddr">192.168.1.1</hostid>, you should be able to run
3525
	</para>
3493
 
3526
 
3494
      <programlisting>ping 192.168.2.1</programlisting>
3527
      <programlisting>ping 192.168.2.1</programlisting>
3495
 
3528
 
Lines 3497-3503 Link Here
3497
        thing on the other gateway machine.</para>
3530
        thing on the other gateway machine.</para>
3498
 
3531
 
3499
      <para>However, you will not be able to reach internal machines
3532
      <para>However, you will not be able to reach internal machines
3500
        on either network yet.  This is because of the routing --
3533
        on either network yet.  This is because of the routing &mdash;
3501
        although the gateway machines know how to reach one another,
3534
        although the gateway machines know how to reach one another,
3502
        they do not know how to reach the network behind each one.</para>
3535
        they do not know how to reach the network behind each one.</para>
3503
 
3536
 
Lines 3516-3527 Link Here
3516
        <hostid role="ipaddr">192.168.1.x</hostid> addresses
3549
        <hostid role="ipaddr">192.168.1.x</hostid> addresses
3517
        instead.</para>
3550
        instead.</para>
3518
 
3551
 
3519
      <para>IP traffic from hosts on one network will now be able to
3552
      <para><acronym>IP</acronym> traffic from hosts on one network will now
3520
        reach hosts on the other network.</para>
3553
        be able to reach hosts on the other network.</para>
3521
 
3554
 
3522
      <para>That has now created two thirds of a VPN between the two
3555
      <para>That has now created two thirds of a <acronym>VPN</acronym> between
3523
        networks, in as much as it is <quote>virtual</quote> and it is a
3556
        the two networks, in as much as it is <quote>virtual</quote> and it is
3524
        <quote>network</quote>.  It is not private yet.  You can test
3557
	a <quote>network</quote>.  It is not private yet.  You can test
3525
        this using &man.ping.8; and &man.tcpdump.1;.  Log in to the
3558
        this using &man.ping.8; and &man.tcpdump.1;.  Log in to the
3526
        gateway host and run</para>
3559
        gateway host and run</para>
3527
 
3560
 
Lines 3542-3551 Link Here
3542
16:10:26.029112 192.168.1.1 &gt; 192.168.2.1: icmp: echo reply
3575
16:10:26.029112 192.168.1.1 &gt; 192.168.2.1: icmp: echo reply
3543
      </programlisting>
3576
      </programlisting>
3544
 
3577
 
3545
      <para>As you can see, the ICMP messages are going back and forth
3578
      <para>As you can see, the <acronym>ICMP</acronym> messages are going
3546
        unencrypted.  If you had used the <option>-s</option> parameter to
3579
        back and forth unencrypted.  If you had used the <option>-s</option>
3547
        &man.tcpdump.1; to grab more bytes of data from the packets you
3580
	parameter to &man.tcpdump.1; to grab more bytes of data from the
3548
        would see more information.</para>
3581
	packets you would see more information.</para>
3549
 
3582
 
3550
      <para>Obviously this is unacceptable.  The next section will
3583
      <para>Obviously this is unacceptable.  The next section will
3551
        discuss securing the link between the two networks so that it
3584
        discuss securing the link between the two networks so that it
Lines 3586-3592 Link Here
3586
    <sect3>
3619
    <sect3>
3587
      <title>Step 2: Securing the link</title>
3620
      <title>Step 2: Securing the link</title>
3588
 
3621
 
3589
      <para>To secure the link we will be using IPsec.  IPsec provides
3622
      <para>To secure the link we will be using <acronym>IPsec</acronym>.
3623
        <acronym>IPsec</acronym> provides
3590
        a mechanism for two hosts to agree on an encryption key, and to
3624
        a mechanism for two hosts to agree on an encryption key, and to
3591
        then use this key in order to encrypt data between the two
3625
        then use this key in order to encrypt data between the two
3592
        hosts.</para>
3626
        hosts.</para>
Lines 3603-3612 Link Here
3603
        <listitem>
3637
        <listitem>
3604
          <para>There must be a mechanism for specifying which traffic
3638
          <para>There must be a mechanism for specifying which traffic
3605
            should be encrypted.  Obviously, you do not want to encrypt
3639
            should be encrypted.  Obviously, you do not want to encrypt
3606
            all your outgoing traffic -- you only want to encrypt the
3640
            all your outgoing traffic &mdash; you only want to encrypt the
3607
            traffic that is part of the VPN.  The rules that you put in
3641
            traffic that is part of the <acronym>VPN</acronym>.  The rules
3608
            place to determine what traffic will be encrypted are called
3642
	    that you put in place to determine what traffic will be encrypted
3609
            <quote>security policies</quote>.</para>
3643
	    are called <quote>security policies</quote>.</para>
3610
         </listitem>
3644
         </listitem>
3611
       </orderedlist>
3645
       </orderedlist>
3612
 
3646
 
Lines 3614-3620 Link Here
3614
         maintained by the kernel, and can be modified by userland
3648
         maintained by the kernel, and can be modified by userland
3615
         programs.  However, before you can do this you must configure the
3649
         programs.  However, before you can do this you must configure the
3616
         kernel to support IPsec and the Encapsulated Security Payload
3650
         kernel to support IPsec and the Encapsulated Security Payload
3617
         (ESP) protocol.  This is done by configuring a kernel with:</para>
3651
         (<acronym>ESP</acronym>) protocol.  This is done by configuring a
3652
	 kernel with:</para>
3618
 
3653
 
3619
       <indexterm>
3654
       <indexterm>
3620
	 <primary>kernel options</primary>
3655
	 <primary>kernel options</primary>
Lines 3637-3643 Link Here
3637
         associations.  You can configure them by hand between two hosts,
3672
         associations.  You can configure them by hand between two hosts,
3638
         which entails choosing the encryption algorithm, encryption keys,
3673
         which entails choosing the encryption algorithm, encryption keys,
3639
         and so forth, or you can use daemons that implement the Internet
3674
         and so forth, or you can use daemons that implement the Internet
3640
         Key Exchange protocol (IKE) to do this for you.</para>
3675
         Key Exchange protocol 
3676
	 (<acronym role="Internet Key Exchange">IKE</acronym>) to do this
3677
	 for you.</para>
3641
 
3678
 
3642
       <para>I recommend the latter.  Apart from anything else, it is
3679
       <para>I recommend the latter.  Apart from anything else, it is
3643
         easier to set up.</para>
3680
         easier to set up.</para>
Lines 3662-3687 Link Here
3662
       <para>There are a number of choices for daemons to manage
3699
       <para>There are a number of choices for daemons to manage
3663
         security associations with FreeBSD.  This article will describe
3700
         security associations with FreeBSD.  This article will describe
3664
         how to use one of these, racoon&nbsp;&mdash; which is available from
3701
         how to use one of these, racoon&nbsp;&mdash; which is available from
3665
	 <filename role="package">security/ipsec-tools</filename> in the &os; Ports
3702
	 <filename role="package">security/ipsec-tools</filename> in the &os;
3666
	 collection.</para>
3703
	 Ports Collection.</para>
3667
 
3704
 
3668
       <indexterm>
3705
       <indexterm>
3669
	 <primary>racoon</primary>
3706
	 <primary>racoon</primary>
3670
       </indexterm>
3707
       </indexterm>
3671
3708
3672
       <para>The <application>racoon</application> software must be run on both gateway hosts.  On each host it
3709
       <para>The <application>racoon</application> software must be run on 
3673
         is configured with the IP address of the other end of the VPN,
3710
         both gateway hosts.  On each host it is configured with the 
3674
         and a secret key (which you choose, and must be the same on both
3711
	 <acronym>IP</acronym> address of the other end of the
3675
         gateways).</para>
3712
	 <acronym>VPN</acronym>, and a secret key (which you choose, and
3713
	 must be the same on both gateways).</para>
3676
 
3714
 
3677
       <para>The two daemons then contact one another, confirm that they
3715
       <para>The two daemons then contact one another, confirm that they
3678
         are who they say they are (by using the secret key that you
3716
         are who they say they are (by using the secret key that you
3679
         configured).  The daemons then generate a new secret key, and use
3717
         configured).  The daemons then generate a new secret key, and use
3680
         this to encrypt the traffic over the VPN.  They periodically
3718
         this to encrypt the traffic over the <acronym>VPN</acronym>.  They
3719
	 periodically
3681
         change this secret, so that even if an attacker were to crack one
3720
         change this secret, so that even if an attacker were to crack one
3682
         of the keys (which is as theoretically close to unfeasible as it
3721
         of the keys (which is as theoretically close to unfeasible as it
3683
         gets) it will not do them much good -- by the time they have cracked
3722
         gets) it will not do them much good &mdash; by the time they have
3684
         the key the two daemons have chosen another one.</para>
3723
	 cracked the key the two daemons have chosen another one.</para>
3685
 
3724
 
3686
       <para>The configuration file for racoon is stored in
3725
       <para>The configuration file for racoon is stored in
3687
         <filename>${PREFIX}/etc/racoon</filename>.  You should find a
3726
         <filename>${PREFIX}/etc/racoon</filename>.  You should find a
Lines 3691-3699 Link Here
3691
         key</quote>.</para>
3730
         key</quote>.</para>
3692
 
3731
 
3693
       <para>The default racoon configuration expects to find this in
3732
       <para>The default racoon configuration expects to find this in
3694
         the file <filename>${PREFIX}/etc/racoon/psk.txt</filename>.  It is important to note
3733
         the file <filename>${PREFIX}/etc/racoon/psk.txt</filename>.  It is
3695
         that the pre-shared key is <emphasis>not</emphasis> the key that will be used to
3734
	 important to note that the pre-shared key is <emphasis>not</emphasis>
3696
         encrypt your traffic across the VPN link, it is simply a token
3735
	 the key that will be used to encrypt your traffic across the 
3736
	 <acronym>VPN</acronym> link, it is simply a token
3697
         that allows the key management daemons to trust one another.</para>
3737
         that allows the key management daemons to trust one another.</para>
3698
3738
3699
       <para><filename>psk.txt</filename> contains a line for each
3739
       <para><filename>psk.txt</filename> contains a line for each
Lines 3705-3727 Link Here
3705
 
3745
 
3706
       <programlisting>W.X.Y.Z            secret</programlisting>
3746
       <programlisting>W.X.Y.Z            secret</programlisting>
3707
 
3747
 
3708
       <para>That is, the <emphasis>public</emphasis> IP address of the remote end,
3748
       <para>That is, the <emphasis>public</emphasis> <acronym>IP</acronym>
3709
         whitespace, and a text string that provides the secret.
3749
         address of the remote end, whitespace, and a text string that
3710
         Obviously, you should not use <quote>secret</quote> as your key -- the normal
3750
	 provides the secret. Obviously, you should not use 
3751
	 <quote>secret</quote> as your key &mdash; the normal
3711
         rules for choosing a password apply.</para>
3752
         rules for choosing a password apply.</para>
3712
 
3753
 
3713
       <para>On gateway host #2 the line would look like this</para>
3754
       <para>On gateway host #2 the line would look like this</para>
3714
 
3755
 
3715
       <programlisting>A.B.C.D            secret</programlisting>
3756
       <programlisting>A.B.C.D            secret</programlisting>
3716
 
3757
 
3717
       <para>That is, the public IP address of the remote end, and the
3758
       <para>That is, the public <acronym>IP</acronym> address of the remote
3759
         end, and the
3718
         same secret key.  <filename>psk.txt</filename> must be mode
3760
         same secret key.  <filename>psk.txt</filename> must be mode
3719
         <literal>0600</literal> (i.e., only read/write to
3761
         <literal>0600</literal> (i.e., only read/write to
3720
         <username>root</username>) before racoon will run.</para>
3762
         <username>root</username>) before racoon will run.</para>
3721
 
3763
 
3722
       <para>You must run racoon on both gateway machines.  You will
3764
       <para>You must run racoon on both gateway machines.  You will
3723
         also need to add some firewall rules to allow the IKE traffic,
3765
         also need to add some firewall rules to allow the
3724
         which is carried over UDP to the ISAKMP (Internet Security Association
3766
	 <acronym>IKE</acronym> traffic,
3767
         which is carried over <acronym>UDP</acronym> to the 
3768
	 <acronym role="Internet Security Association Key Management
3769
Protocol">ISAKMP</acronym> (Internet Security Association
3725
         Key Management Protocol) port.  Again, this should be fairly early in
3770
         Key Management Protocol) port.  Again, this should be fairly early in
3726
         your firewall ruleset.</para>
3771
         your firewall ruleset.</para>
3727
 
3772
 
Lines 3732-3738 Link Here
3732
       <para>Once racoon is running you can try pinging one gateway host
3777
       <para>Once racoon is running you can try pinging one gateway host
3733
         from the other.  The connection is still not encrypted, but
3778
         from the other.  The connection is still not encrypted, but
3734
         racoon will then set up the security associations between the two
3779
         racoon will then set up the security associations between the two
3735
         hosts -- this might take a moment, and you may see this as a
3780
         hosts &mdash; this might take a moment, and you may see this as a
3736
         short delay before the ping commands start responding.</para>
3781
         short delay before the ping commands start responding.</para>
3737
 
3782
 
3738
       <para>Once the security association has been set up you can
3783
       <para>Once the security association has been set up you can
Lines 3750-3761 Link Here
3750
         link.</para>
3795
         link.</para>
3751
 
3796
 
3752
       <para>Each IP packet that you send out has a header that contains
3797
       <para>Each IP packet that you send out has a header that contains
3753
         data about the packet.  The header includes the IP addresses of
3798
         data about the packet.  The header includes the
3754
         both the source and destination.  As we already know, private IP
3799
	 <acronym>IP</acronym> addresses of both the source and destination.
3800
	 As we already know, private <acronym>IP</acronym>
3755
         addresses, such as the <hostid role="ipaddr">192.168.x.y</hostid>
3801
         addresses, such as the <hostid role="ipaddr">192.168.x.y</hostid>
3756
         range are not supposed to appear on the public Internet.
3802
         range are not supposed to appear on the public Internet.
3757
         Instead, they must first be encapsulated inside another packet.
3803
         Instead, they must first be encapsulated inside another packet.
3758
         This packet must have the public source and destination IP
3804
         This packet must have the public source and destination
3805
	 <acronym>IP</acronym>
3759
         addresses substituted for the private addresses.</para>
3806
         addresses substituted for the private addresses.</para>
3760
 
3807
 
3761
       <para>So if your outgoing packet started looking like this:</para>
3808
       <para>So if your outgoing packet started looking like this:</para>
Lines 3805-3815 Link Here
3805
 
3852
 
3806
       <para>This encapsulation is carried out by the
3853
       <para>This encapsulation is carried out by the
3807
         <devicename>gif</devicename> device.  As
3854
         <devicename>gif</devicename> device.  As
3808
         you can see, the packet now has real IP addresses on the outside,
3855
         you can see, the packet now has real <acronym>IP<acronym> addresses
3856
	 on the outside,
3809
         and our original packet has been wrapped up as data inside the
3857
         and our original packet has been wrapped up as data inside the
3810
         packet that will be put out on the Internet.</para>
3858
         packet that will be put out on the Internet.</para>
3811
 
3859
 
3812
       <para>Obviously, we want all traffic between the VPNs to be
3860
       <para>Obviously, we want all traffic between the
3861
         <acronym>VPN</acronym>s to be
3813
         encrypted.  You might try putting this in to words, as:</para>
3862
         encrypted.  You might try putting this in to words, as:</para>
3814
3863
3815
       <para><quote>If a packet leaves from <hostid
3864
       <para><quote>If a packet leaves from <hostid
Lines 3848-3856 Link Here
3848
         filename that contains configuration instructions.</para>
3897
         filename that contains configuration instructions.</para>
3849
 
3898
 
3850
       <para>The configuration on gateway host #1 (which has the public
3899
       <para>The configuration on gateway host #1 (which has the public
3851
         IP address <hostid role="ipaddr">A.B.C.D</hostid>) to force all
3900
         <acronym>IP</acronym> address <hostid role="ipaddr">A.B.C.D</hostid>)
3852
         outbound traffic to <hostid role="ipaddr">W.X.Y.Z</hostid> to be
3901
         to force all outbound traffic to <hostid role="ipaddr">W.X.Y.Z</hostid>
3853
         encrypted is:</para>
3902
	 to be encrypted is:</para>
3854
 
3903
 
3855
       <programlisting>
3904
       <programlisting>
3856
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P out ipsec esp/tunnel/A.B.C.D-W.X.Y.Z/require;
3905
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P out ipsec esp/tunnel/A.B.C.D-W.X.Y.Z/require;
Lines 3865-3871 Link Here
3865
         to add a rule to the secure policy database.  The rest of this
3914
         to add a rule to the secure policy database.  The rest of this
3866
         line specifies which packets will match this policy.  <hostid
3915
         line specifies which packets will match this policy.  <hostid
3867
         role="ipaddr">A.B.C.D/32</hostid> and <hostid
3916
         role="ipaddr">A.B.C.D/32</hostid> and <hostid
3868
         role="ipaddr">W.X.Y.Z/32</hostid> are the IP addresses and
3917
         role="ipaddr">W.X.Y.Z/32</hostid> are the <acronym>IP</acronym>
3918
	 addresses and
3869
         netmasks that identify the network or hosts that this policy will
3919
         netmasks that identify the network or hosts that this policy will
3870
         apply to.  In this case, we want it to apply to traffic between
3920
         apply to.  In this case, we want it to apply to traffic between
3871
         these two hosts.  <option>ipencap</option> tells the kernel that
3921
         these two hosts.  <option>ipencap</option> tells the kernel that
Lines 3893-3907 Link Here
3893
         <option>out</option> in this case, and the necessary reversal of
3943
         <option>out</option> in this case, and the necessary reversal of
3894
         the IP addresses.</para>
3944
         the IP addresses.</para>
3895
 
3945
 
3896
       <para>The other gateway host (which has the public IP address
3946
       <para>The other gateway host (which has the public
3897
         <hostid role="ipaddr">W.X.Y.Z</hostid>) will need similar rules.</para>
3947
         <acronym>IP</acronym> address <hostid role="ipaddr">W.X.Y.Z</hostid>)
3948
         will need similar rules.</para>
3898
 
3949
 
3899
       <programlisting>spdadd W.X.Y.Z/32 A.B.C.D/32 ipencap -P out ipsec esp/tunnel/W.X.Y.Z-A.B.C.D/require;
3950
       <programlisting>spdadd W.X.Y.Z/32 A.B.C.D/32 ipencap -P out ipsec esp/tunnel/W.X.Y.Z-A.B.C.D/require;
3900
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P in ipsec esp/tunnel/A.B.C.D-W.X.Y.Z/require;</programlisting>
3951
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P in ipsec esp/tunnel/A.B.C.D-W.X.Y.Z/require;</programlisting>
3901
 
3952
 
3902
       <para>Finally, you need to add firewall rules to allow ESP and
3953
       <para>Finally, you need to add firewall rules to allow 
3903
        IPENCAP packets back and forth.  These rules will need to be
3954
         <acronym>ESP</acronym> and <acronym>IPENCAP</acronym> packets back
3904
        added to both hosts.</para>
3955
	 and forth.  These rules will need to be added to both hosts.</para>
3905
 
3956
 
3906
       <programlisting>ipfw add 1 allow esp from A.B.C.D to W.X.Y.Z
3957
       <programlisting>ipfw add 1 allow esp from A.B.C.D to W.X.Y.Z
3907
ipfw add 1 allow esp from W.X.Y.Z to A.B.C.D
3958
ipfw add 1 allow esp from W.X.Y.Z to A.B.C.D
Lines 3944-3950 Link Here
3944
	  </textobject>
3995
	  </textobject>
3945
	</mediaobject>
3996
	</mediaobject>
3946
3997
3947
       <para>When they are received by the far end of the VPN they will
3998
       <para>When they are received by the far end of the
3999
         <acronym>VPN</acronym> they will
3948
         first be decrypted (using the security associations that have
4000
         first be decrypted (using the security associations that have
3949
         been negotiated by racoon).  Then they will enter the
4001
         been negotiated by racoon).  Then they will enter the
3950
         <devicename>gif</devicename> interface, which will unwrap
4002
         <devicename>gif</devicename> interface, which will unwrap
Lines 3966-3977 Link Here
3966
 
4018
 
3967
       <programlisting>XXX tcpdump output</programlisting>
4019
       <programlisting>XXX tcpdump output</programlisting>
3968
 
4020
 
3969
       <para>Now, as you can see, &man.tcpdump.1; shows the ESP packets.  If
4021
       <para>Now, as you can see, &man.tcpdump.1; shows the
4022
         <acronym>ESP</acronym> packets.  If
3970
         you try to examine them with the <option>-s</option> option you will see
4023
         you try to examine them with the <option>-s</option> option you will see
3971
         (apparently) gibberish, because of the encryption.</para>
4024
         (apparently) gibberish, because of the encryption.</para>
3972
 
4025
 
3973
      <para>Congratulations.  You have just set up a VPN between two
4026
      <para>Congratulations.  You have just set up a <acronym>VPN</acronym>
3974
        remote sites.</para>
4027
        between two remote sites.</para>
3975
 
4028
 
3976
      <itemizedlist>
4029
      <itemizedlist>
3977
        <title>Summary</title>
4030
        <title>Summary</title>
Lines 3986-3992 Link Here
3986
          <para>Install <filename
4039
          <para>Install <filename
3987
            role="package">security/ipsec-tools</filename>.  Edit
4040
            role="package">security/ipsec-tools</filename>.  Edit
3988
            <filename>${PREFIX}/etc/racoon/psk.txt</filename> on both
4041
            <filename>${PREFIX}/etc/racoon/psk.txt</filename> on both
3989
            gateway hosts, adding an entry for the remote host's IP
4042
            gateway hosts, adding an entry for the remote host's
4043
	    <acronym>IP</acronym>
3990
            address and a secret key that they both know.  Make sure
4044
            address and a secret key that they both know.  Make sure
3991
            this file is mode 0600.</para>
4045
            this file is mode 0600.</para>
3992
        </listitem>
4046
        </listitem>
Lines 4020-4026 Link Here
4020
</programlisting>
4074
</programlisting>
4021
        </listitem>
4075
        </listitem>
4022
        <listitem>
4076
        <listitem>
4023
          <para>Add firewall rules to allow IKE, ESP, and IPENCAP
4077
          <para>Add firewall rules to allow <acronym>IKE</acronym>,
4078
	    <acronym>ESP</acronym>, and <acronym>IPENCAP</acronym>
4024
            traffic to both hosts:</para>
4079
            traffic to both hosts:</para>
4025
 
4080
 
4026
          <programlisting>
4081
          <programlisting>
Lines 4034-4043 Link Here
4034
        </listitem>
4089
        </listitem>
4035
      </itemizedlist>
4090
      </itemizedlist>
4036
4091
4037
      <para>The previous two steps should suffice to get the VPN up and
4092
      <para>The previous two steps should suffice to get the
4093
       <acronym>VPN</acronym> up and
4038
        running.  Machines on each network will be able to refer to one
4094
        running.  Machines on each network will be able to refer to one
4039
        another using IP addresses, and all traffic across the link will
4095
        another using <acronym>IP</acornym> addresses, and all traffic across
4040
        be automatically and securely encrypted.</para>
4096
	the link will be automatically and securely encrypted.</para>
4041
    </sect3> 
4097
    </sect3> 
4042
    </sect2> 
4098
    </sect2> 
4043
  </sect1>
4099
  </sect1>
Lines 4065-4078 Link Here
4065
      access remote machines securely.  It can be used as a direct
4121
      access remote machines securely.  It can be used as a direct
4066
      replacement for <command>rlogin</command>,
4122
      replacement for <command>rlogin</command>,
4067
      <command>rsh</command>, <command>rcp</command>, and
4123
      <command>rsh</command>, <command>rcp</command>, and
4068
      <command>telnet</command>.  Additionally, TCP/IP
4124
      <command>telnet</command>.  Additionally, <acronym>TCP/IP</acronym>
4069
      connections can be tunneled/forwarded securely through SSH.
4125
      connections can be tunneled/forwarded securely through <acronym
4126
      role="Secure Shell">SSH</acronym>.
4070
      <application>OpenSSH</application> encrypts all traffic to effectively eliminate eavesdropping,
4127
      <application>OpenSSH</application> encrypts all traffic to effectively eliminate eavesdropping,
4071
      connection hijacking, and other network-level attacks.</para>
4128
      connection hijacking, and other network-level attacks.</para>
4072
4129
4073
    <para><application>OpenSSH</application> is maintained by the OpenBSD project, and is based
4130
    <para><application>OpenSSH</application> is maintained by the OpenBSD
4131
      project, and is based
4074
      upon SSH v1.2.12 with all the recent bug fixes and updates.  It
4132
      upon SSH v1.2.12 with all the recent bug fixes and updates.  It
4075
      is compatible with both SSH protocols 1 and 2.</para>
4133
      is compatible with both <acronym>SSH</acronym> protocols 1 and 2.</para>
4076
4134
4077
    <sect2>
4135
    <sect2>
4078
      <title>Advantages of Using OpenSSH</title>
4136
      <title>Advantages of Using OpenSSH</title>
Lines 4124-4135 Link Here
4124
4182
4125
      <para>The login will continue just as it would have if a session was
4183
      <para>The login will continue just as it would have if a session was
4126
        created using <command>rlogin</command> or
4184
        created using <command>rlogin</command> or
4127
        <command>telnet</command>.  SSH utilizes a key fingerprint
4185
        <command>telnet</command>.  <acronym>SSH</acronym> utilizes a key
4128
        system for verifying the authenticity of the server when the 
4186
	fingerprint system for verifying the authenticity of the server when
4129
        client connects.  The user is prompted to enter
4187
	the  client connects.  The user is prompted to enter
4130
	<literal>yes</literal> only when
4188
	<literal>yes</literal> only when
4131
        connecting for the first time.  Future attempts to login are all
4189
        connecting for the first time.  Future attempts to login are all
4132
        verified against the saved fingerprint key.  The SSH client
4190
        verified against the saved fingerprint key.  The
4191
	<acronym>SSH</acronym> client
4133
        will alert you if the saved fingerprint differs from the
4192
        will alert you if the saved fingerprint differs from the
4134
        received fingerprint on future login attempts.  The fingerprints
4193
        received fingerprint on future login attempts.  The fingerprints
4135
        are saved in <filename>~/.ssh/known_hosts</filename>, or
4194
        are saved in <filename>~/.ssh/known_hosts</filename>, or
Lines 4137-4143 Link Here
4137
	fingerprints.</para>
4196
	fingerprints.</para>
4138
4197
4139
      <para>By default, recent versions of the
4198
      <para>By default, recent versions of the
4140
        <application>OpenSSH</application> servers only accept SSH v2
4199
        <application>OpenSSH</application> servers only accept
4200
	<acronym>SSH</acronym>v2
4141
        connections.  The client will use version 2 if possible and
4201
        connections.  The client will use version 2 if possible and
4142
        will fall back to version 1.  The client can also be forced to
4202
        will fall back to version 1.  The client can also be forced to
4143
        use one or the other by passing it the <option>-1</option> or
4203
        use one or the other by passing it the <option>-1</option> or
Lines 4170-4177 Link Here
4170
      <para>The arguments passed to &man.scp.1; are similar
4230
      <para>The arguments passed to &man.scp.1; are similar
4171
	to &man.cp.1;, with the file or files in the first
4231
	to &man.cp.1;, with the file or files in the first
4172
	argument, and the destination in the second.  Since the file is
4232
	argument, and the destination in the second.  Since the file is
4173
	fetched over the network, through SSH, one or more of the file
4233
	fetched over the network, through <acronym>SSH</acronym>, one or
4174
	arguments takes on the form
4234
	more of the file arguments takes on the form
4175
	<option>user@host:&lt;path_to_remote_file&gt;</option>.</para>
4235
	<option>user@host:&lt;path_to_remote_file&gt;</option>.</para>
4176
4236
4177
    </sect2>
4237
    </sect2>
Lines 4201-4207 Link Here
4201
      <title>ssh-keygen</title>
4261
      <title>ssh-keygen</title>
4202
4262
4203
      <para>Instead of using passwords, &man.ssh-keygen.1; can
4263
      <para>Instead of using passwords, &man.ssh-keygen.1; can
4204
        be used to generate DSA or RSA keys to authenticate a user:</para>
4264
        be used to generate <acronym>DSA</acronym> or <acronym>RSA</acronym>
4265
	keys to authenticate a user:</para>
4205
4266
4206
      <screen>&prompt.user; <userinput>ssh-keygen -t <replaceable>dsa</replaceable></userinput>
4267
      <screen>&prompt.user; <userinput>ssh-keygen -t <replaceable>dsa</replaceable></userinput>
4207
Generating public/private dsa key pair.
4268
Generating public/private dsa key pair.
Lines 4223-4234 Link Here
4223
        <filename>~/.ssh/id_rsa.pub</filename>, respectively for DSA and
4284
        <filename>~/.ssh/id_rsa.pub</filename>, respectively for DSA and
4224
        RSA key types.  The public key must be placed in
4285
        RSA key types.  The public key must be placed in
4225
        <filename>~/.ssh/authorized_keys</filename> of the remote
4286
        <filename>~/.ssh/authorized_keys</filename> of the remote
4226
        machine in order for the setup to work.  Similarly, RSA version
4287
        machine in order for the setup to work.  Similarly,
4227
        1 public keys should be placed in
4288
	<acronym>RSA</acronym> version 1 public keys should be placed in
4228
        <filename>~/.ssh/authorized_keys</filename>.</para>
4289
        <filename>~/.ssh/authorized_keys</filename>.</para>
4229
4290
4230
      <para>This will allow connection to the remote machine based upon
4291
      <para>This will allow connection to the remote machine based upon
4231
        SSH keys instead of passwords.</para>
4292
        <acronym>SSH</acronym> keys instead of passwords.</para>
4232
4293
4233
      <para>If a passphrase is used in &man.ssh-keygen.1;, the user
4294
      <para>If a passphrase is used in &man.ssh-keygen.1;, the user
4234
        will be prompted for a password each time in order to use the
4295
        will be prompted for a password each time in order to use the
Lines 4246-4252 Link Here
4246
      <title>ssh-agent and ssh-add</title>
4307
      <title>ssh-agent and ssh-add</title>
4247
4308
4248
      <para>The &man.ssh-agent.1; and &man.ssh-add.1; utilities provide
4309
      <para>The &man.ssh-agent.1; and &man.ssh-add.1; utilities provide
4249
        methods for <application>SSH</application> keys to be loaded
4310
        methods for <application>ssh</application> keys to be loaded
4250
        into memory for use, without needing to type the passphrase
4311
        into memory for use, without needing to type the passphrase
4251
        each time.</para>
4312
        each time.</para>
4252
4313
Lines 4283-4289 Link Here
4283
        launch <application>XFCE</application>, every time X11 starts.
4344
        launch <application>XFCE</application>, every time X11 starts.
4284
        Then once that is done and X11 has been restarted so that the
4345
        Then once that is done and X11 has been restarted so that the
4285
        changes can take effect, simply run &man.ssh-add.1; to load
4346
        changes can take effect, simply run &man.ssh-add.1; to load
4286
        all of your SSH keys.</para>
4347
        all of your <acronym>SSH</acronym> keys.</para>
4287
    </sect2>
4348
    </sect2>
4288
4349
4289
    <sect2 id="security-ssh-tunneling">
4350
    <sect2 id="security-ssh-tunneling">
Lines 4312-4318 Link Here
4312
	  <listitem>
4373
	  <listitem>
4313
	    <para>Forces <command>ssh</command> to use version 2 of
4374
	    <para>Forces <command>ssh</command> to use version 2 of
4314
	      the protocol. (Do not use if you are working with older
4375
	      the protocol. (Do not use if you are working with older
4315
	      SSH servers)</para>
4376
	      <acronym>SSH</acronym> servers)</para>
4316
	  </listitem>
4377
	  </listitem>
4317
	</varlistentry>
4378
	</varlistentry>
4318
4379
Lines 4349-4377 Link Here
4349
	  <term><option>user@foo.example.com</option></term>
4410
	  <term><option>user@foo.example.com</option></term>
4350
4411
4351
	  <listitem>
4412
	  <listitem>
4352
	    <para>The remote SSH server.</para>
4413
	    <para>The remote <acronym>SSH</acronym> server.</para>
4353
	  </listitem>
4414
	  </listitem>
4354
	</varlistentry>
4415
	</varlistentry>
4355
      </variablelist>
4416
      </variablelist>
4356
4417
4357
4418
4358
      <para>An SSH tunnel works by creating a listen socket on
4419
      <para>A <acronym>SSH</acronym> tunnel works by creating a listen socket
4359
	<hostid>localhost</hostid> on the specified port.
4420
        om <hostid>localhost</hostid> on the specified port.
4360
	It then forwards any connection received
4421
	It then forwards any connection received
4361
	on the local host/port via the SSH connection to the specified
4422
	on the local host/port via the <acronym>SSH</acronym> connection to
4362
	remote host and port.</para>
4423
	the specified remote host and port.</para>
4363
4424
4364
      <para>In the example, port <replaceable>5023</replaceable> on
4425
      <para>In the example, port <replaceable>5023</replaceable> on
4365
	<hostid>localhost</hostid> is being forwarded to port
4426
	<hostid>localhost</hostid> is being forwarded to port
4366
	<replaceable>23</replaceable> on <hostid>localhost</hostid>
4427
	<replaceable>23</replaceable> on <hostid>localhost</hostid>
4367
	of the remote machine.  Since <replaceable>23</replaceable> is <application>telnet</application>,
4428
	of the remote machine.  Since <replaceable>23</replaceable> is 
4368
	this would create a secure <application>telnet</application> session through an SSH tunnel.</para>
4429
	<application>telnet</application>,
4369
4430
	this would create a secure <application>telnet</application> session
4370
      <para>This can be used to wrap any number of insecure TCP
4431
	through an <acronym>SSH</acronym> tunnel.</para>
4371
        protocols such as SMTP, POP3, FTP, etc.</para>
4432
4433
      <para>This can be used to wrap any number of insecure
4434
        <acronym>TCP</acronym> protocols such as <acronym>SMTP</acronym>,
4435
	<acronym>POP3</acronym>, <acronym>FTP</acronym>, etc.</para>
4372
4436
4373
      <example>
4437
      <example>
4374
	<title>Using SSH to Create a Secure Tunnel for SMTP</title>
4438
	<title>Using <acronym>SSH</acronym> to Create a Secure Tunnel for
4439
	  <acronym>SMTP</acronym></title>
4375
4440
4376
        <screen>&prompt.user; <userinput>ssh -2 -N -f -L <replaceable>5025:localhost:25 user@mailserver.example.com</replaceable></userinput>
4441
        <screen>&prompt.user; <userinput>ssh -2 -N -f -L <replaceable>5025:localhost:25 user@mailserver.example.com</replaceable></userinput>
4377
user@mailserver.example.com's password: <userinput>*****</userinput>
4442
user@mailserver.example.com's password: <userinput>*****</userinput>
Lines 4383-4434 Link Here
4383
4448
4384
        <para>This can be used in conjunction with an
4449
        <para>This can be used in conjunction with an
4385
          &man.ssh-keygen.1; and additional user accounts to create a
4450
          &man.ssh-keygen.1; and additional user accounts to create a
4386
          more seamless/hassle-free SSH tunneling environment.  Keys
4451
          more seamless/hassle-free <acronym>SSH</acronym> tunneling
4387
          can be used in place of typing a password, and the tunnels
4452
	  environment.  Keys can be used in place of typing a password, an
4388
          can be run as a separate user.</para>
4453
	  the tunnels can be run as a separate user.</para>
4389
      </example>
4454
      </example>
4390
4455
4391
      <sect3>
4456
      <sect3>
4392
	<title>Practical SSH Tunneling Examples</title>
4457
	<title>Practical <acronym>SSH</acronym> Tunneling Examples</title>
4393
4458
4394
	<sect4>
4459
	<sect4>
4395
	  <title>Secure Access of a POP3 Server</title>
4460
	  <title>Secure Access of a <acronym>POP3</acronym> Server</title>
4396
4461
4397
	  <para>At work, there is an SSH server that accepts
4462
	  <para>At work, there is an <acronym>SSH</acronym> server that accepts
4398
	    connections from the outside.  On the same office network
4463
	    connections from the outside.  On the same office network
4399
	    resides a mail server running a POP3 server.  The network,
4464
	    resides a mail server running a <acronym>POP3</acronym> server.
4465
	    The network,
4400
	    or network path between your home and office may or may not
4466
	    or network path between your home and office may or may not
4401
	    be completely trustable.  Because of this, you need to check
4467
	    be completely trustable.  Because of this, you need to check
4402
	    your e-mail in a secure manner.  The solution is to create
4468
	    your e-mail in a secure manner.  The solution is to create
4403
	    an SSH connection to your office's SSH server, and tunnel
4469
	    an <command>ssh</command> connection to your office's
4470
	    <acronym>SSH</acronym> server, and tunnel
4404
	    through to the mail server.</para>
4471
	    through to the mail server.</para>
4405
4472
4406
	  <screen>&prompt.user; <userinput>ssh -2 -N -f -L <replaceable>2110:mail.example.com:110 user@ssh-server.example.com</replaceable></userinput>
4473
	  <screen>&prompt.user; <userinput>ssh -2 -N -f -L <replaceable>2110:mail.example.com:110 user@ssh-server.example.com</replaceable></userinput>
4407
user@ssh-server.example.com's password: <userinput>******</userinput></screen>
4474
user@ssh-server.example.com's password: <userinput>******</userinput></screen>
4408
4475
4409
	  <para>When the tunnel is up and running, you can point your
4476
	  <para>When the tunnel is up and running, you can point your
4410
	    mail client to send POP3 requests to <hostid>localhost</hostid>
4477
	    mail client to send <acronym>POP3</acronym> requests to
4478
	    <hostid>localhost</hostid>
4411
	    port 2110.  A connection here will be forwarded securely across
4479
	    port 2110.  A connection here will be forwarded securely across
4412
	    the tunnel to <hostid>mail.example.com</hostid>.</para>
4480
	    the tunnel to <hostid>mail.example.com</hostid>.</para>
4413
	</sect4>
4481
	</sect4>
4414
4482
4415
	<sect4>
4483
	<sect4>
4416
	  <title>Bypassing a Draconian Firewall</title>
4484
	  <title>Bypassing a draconian Firewall</title>
4417
4485
4418
	  <para>Some network administrators impose extremely draconian
4486
	  <para>Some network administrators impose extremely draconian
4419
	    firewall rules, filtering not only incoming connections,
4487
	    firewall rules, filtering not only incoming connections,
4420
	    but outgoing connections.  You may be only given access
4488
	    but outgoing connections.  You may be only given access
4421
	    to contact remote machines on ports 22 and 80 for SSH
4489
	    to contact remote machines on ports 22 and 80 for
4422
	    and web surfing.</para>
4490
	    <acronym>SSH</acronym> and web surfing.</para>
4423
4491
4424
	  <para>You may wish to access another (perhaps non-work
4492
	  <para>You may wish to access another (perhaps non-work
4425
	    related) service, such as an Ogg Vorbis server to stream
4493
	    related) service, such as an Ogg Vorbis server to stream
4426
	    music.  If this Ogg Vorbis server is streaming on some other
4494
	    music.  If this Ogg Vorbis server is streaming on some other
4427
	    port than 22 or 80, you will not be able to access it.</para>
4495
	    port than 22 or 80, you will not be able to access it.</para>
4428
4496
4429
	  <para>The solution is to create an SSH connection to a machine
4497
	  <para>The solution is to create an <acronym>SSH</acronym> connection
4430
	    outside of your network's firewall, and use it to tunnel to
4498
	    to a machine outside of your network's firewall, and use it to
4431
	    the Ogg Vorbis server.</para>
4499
	    tunnel to the Ogg Vorbis server.</para>
4432
4500
4433
	  <screen>&prompt.user; <userinput>ssh -2 -N -f -L <replaceable>8888:music.example.com:8000 user@unfirewalled-system.example.org</replaceable></userinput>
4501
	  <screen>&prompt.user; <userinput>ssh -2 -N -f -L <replaceable>8888:music.example.com:8000 user@unfirewalled-system.example.org</replaceable></userinput>
4434
user@unfirewalled-system.example.org's password: <userinput>*******</userinput></screen>
4502
user@unfirewalled-system.example.org's password: <userinput>*******</userinput></screen>
Lines 4501-4507 Link Here
4501
4569
4502
    <para>In conjunction with file system enhancements like snapshots, FreeBSD 5.0
4570
    <para>In conjunction with file system enhancements like snapshots, FreeBSD 5.0
4503
      and later offers the security of File System Access Control Lists
4571
      and later offers the security of File System Access Control Lists
4504
      (<acronym>ACLs</acronym>).</para>
4572
      (<acronym role="Access Control Lists">ACLs</acronym>).</para>
4505
4573
4506
    <para>Access Control Lists extend the standard &unix;
4574
    <para>Access Control Lists extend the standard &unix;
4507
      permission model in a highly compatible (&posix;.1e) way.  This feature
4575
      permission model in a highly compatible (&posix;.1e) way.  This feature

Return to bug 105456