Connection Security
Connection Security
1
TÀI LIỆU THAM KHẢO
Andrew Lockhart, Network Security Hacks, 2ed
2
CONTENTS
IP SECURITY (IPsec)
SSH
SSL & TLS
VPN
3
IP security: Overview (1/3)
IPsec is a security protocol that operates at the Internet layer of the
TCP/IP protocol stack.
IPsec is optional with IPv4 and is not implemented by all operating
systems. IPsec is required by the IPv6 specification.
4
IP security: Overview (2/3)
IPsec can be used to secure traffic on a LAN or on a VPN. IPsec
can be configured to offer the following:
▲ Confidentiality
▲ Authentication
▲ Data integrity
▲ Packet filtering
▲ Protection against data reply attacks
5
IP security: Overview (3/3)
IPsec architecture is described in RFC 2401. IPsec
6
IP security: Authentication Header
AH protects the integrity and authenticity of IP
7
IP security: Encapsulating Security
Payload (ESP)
ESP can be used to provide confidentiality, data
8
ESP Modes (1/2)
Transport mode: the upper-layer protocol frame is
encapsulated.The IP header is not encrypted. Transport mode
provides end-to-end protection of packets exchanged between
two end hosts. Both nodes have to be IPsec aware
9
ESP Modes (2/2)
Tunnel mode: an entire datagram plus security fields are treated as
security gateways on behalf of end hosts. The end hosts need not be
IPsec aware.
On the other hand, you get traffic flow confidentiality as the inner IP
10
and destination addresses are hidden.
11
IP security: Security Associations
(SA)
To generate, decrypt, or verify an ESP packet a system has to know which
algorithm and which key to use. This information is stored in a security
association (SA)
13
Set up IPsec under Linux
The most popular way of configuring IPsec connections
under Linux is by using the Openswan
(http://www.openswan.org) package
Openswan is made up of two components: pluto and,
optionally, KerneL IP Security (KLIPS)
Linux kernel includes support for IPsec, but KLIPS can be
used instead for some additional features.
pluto is the user-land daemon that controls Internet Key
Exchange (IKE) negotiation
14
Set up IPsec…
Download and install
$ tar xfz openswan-2.4.6rc3.tar.gz
$ cd openswan-2.4.6rc3
$ make programs
# cd /usr/src/kernels/linux-2.6.14.6
# zcat /tmp/openswan-2.4.6rc3.kernel-2.6-klips.patch.gz | patch -p1
15
Set up IPsec…
If patched kernel for KLIPS, rebuild it and reboot
with it.
If chose to use the kernel’s built-in IPsec support,
can go ahead and start it now:
# /etc/init.d/ipsec start
# /usr/local/sbin/ipsec verify
16
Configuring Openswan
Openswan’s configuration is controlled by two
configuration files:
/etc/ipsec.conf and /etc/ipsec.secrets.
The ipsec.conf file breaks a VPN connection into right
and left segments.
This is merely a logical division. The segment on the
left can be either the internal or the external network;
this allows the same configuration file to be used for
both ends of a VPN network-to-network tunnel.
17
Example
Adding an entry like this to ipsec.conf creates an
encrypted tunnel between two hosts:
conn host-to-host
left=192.168.0.64
[email protected]
#leftnexthop=%defaultroute
right=192.168.0.62
[email protected]
#rightnexthop=%defaultroute
auto=add
18
For authentication purposes, this connection uses RSA signatures, which
are obtained by running /usr/local/sbin/ipsec showhostkey on both hosts
19
Copy the configuration file to both hosts and restart
the ipsec service on both systems:
# /etc/init.d/ipsec restart
ipsec_setup: Stopping Openswan IPsec...
ipsec_setup: Starting Openswan IPsec 2.4.6rc3...
ipsec_setup: insmod /lib/modules/2.6.16-
1.2115_FC4/kernel/net/key/af_key.ko
ipsec_setup: insmod /lib/modules/2.6.16-
1.2115_FC4/kernel/net/ipv4/xfrm4_
tunnel.ko
20
To create the IPsec connection by running the
following command on one of the hosts:
$ ping spek.nnc
$ ping colossus.nnc
21
Set Up IPsec under FreeBSD & OpenBSD
• Use IPsec the OpenBSD way, it’s compiled into the kernel that
ships with each release and is enabled by default
• Create the appropriate /etc/isakmpd/isakmpd.conf and
/etc/isakmpd/isakmpd.policy files and start isakmpd (the IPsec
key-management daemon)
22
Configuring IPsec on a Windows
Network
Can enable and configure the IPsec protocol with
23
Encrypt Traffic Automatically with
Openswan
Opportunistic encryption: Openswan transparently
24
SSH
SSH creates a channel for running a shell on a remote computer,
with end-to-end encryption between the two systems
25
SSH has a client/server architecture
26
SSH is a protocol, SSH protocol covers authentication,
encryption, and the integrity of data transmitted over a
network
27
Protocols, Products, Clients
Protocols are denoted with dashes: SSH-1, SSH-2.
28
Overview of SSH Features
Secure Remote Logins
Secure File Transfer
Secure Remote Command Execution
Keys and Agents
Access Control
Port Forwarding
29
Port Forwarding
SSH uses TCP/IP as its transport mechanism,
30
Direct client/server connection
(no forwarding)
A forwarded port
A forwarded connection
31
Local forwarding
Remote forwarding
32
Off-host port forwarding
Bypassing a Firewall
33
Forward and Encrypt Traffic with
SSH
Keep network traffic to arbitrary ports secure with
switch:
# ssh -f -N -L 110:mailhost:110 user@mailhost
34
Port fowarding: Example
H S
IMAP- IMAP Server
capable email Run SSH
reader server
IMAP uses TCP port 143
35
Local port forwarding
To tunnel the IMAP connection through SSH, we need to pick a local port on home
machine H (between 1024 and 65535) and forward it to the remote socket (S,143).
Creating the tunnel:
$ ssh -L2001:localhost:143 S
–L option specifies local forwarding, in which the TCP client is on the local machine with
local port to listen on (2001), the remote machine name or IP address (S), and the
To make use of the tunnel, configuring email program to connect to port 2001 on home
36
Remote forwarding : A remotely forwarded port is just like a local
one, but the directions are reversed. Client is remote, its server is
local, and a forwarded connection is from the remote machine.
Create a secure tunnel for remote clients (on machine H) to reach the IMAP
server on port 143:
$ ssh -R2001:localhost:143 H
37
Use SSH As a SOCKS Proxy
Local “dynamic” application-level port forwarding:
38
Use SSH As a SOCKS Proxy:
Example
To set up a SOCKS 4 proxy from local port 8080 to
39
40
SSL and TLS
SSL and TLS are protocols that provide session encryption and integrity for
packets sent from one computer to another.
They also provide authentication of the server to the client and (optionally)
of the the client to the server through X.509 certificates (digital certificates)
41
SSL and TLS (2/2)
The most common use of SSL is between a web client
and a web server because it is supported by web browsers
and web servers on all platforms and has become the
standard for encrypting HTTP traffic
HTTP over SSL uses port 443 by default, a firewall
between the Internet and a web server that uses SSL on its
default port would need to allow incoming and outgoing
traffic on port 443
SSL has two components, the SSL Handshake Protocol and
the SSL Record Layer.
42
Encrypt and Tunnel Traffic with SSL
43
Configuring stunnel: the basic form of a configuration file
45
VPN: PPTP
Point-to-Point Tunneling Protocol : PPTP is a
Layer 2 tunneling protocol that encapsulates PPP
packets into IP datagrams by adding a Generic
Routing Encapsulation (GRE) header and an IP
header
46
VPN: L2TP
Layer 2 Tunneling Protocol (L2TP) is an industry-
standard tunneling protocol.
L2TP provides tunneling and authentication, and
utilizes IPsec to provide encryption
47
VPN: Hardware VPN Solutions
Hardware VPN solutions that provide both IPsec
48
Create a Cross-Platform VPN
OpenVPN (http://openvpn.sourceforge.net)
library
Openvpn program
49
Installing OpenVPN
Windows: download, install and configure
51
The End
52