\documentclass[12pt]{beamer}
\usepackage{amsmath}
\usepackage{url}
\usepackage{ucs}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
% Manual syntax highlighting
\newcommand{\synfunc} [1]{\color{blue!50!black}#1\color{black}}
\newcommand{\synstr} [1]{\color{red!50!black}#1\color{black}}
\newcommand{\synvar} [1]{\color{purple!50!black}#1\color{black}}
\newcommand{\synclass} [1]{\color{green!50!black}#1\color{black}}
\newcommand{\syncomment}[1]{\color{blue!20!black}#1\color{black}}
\newcommand{\syncool} [1]{\color{beamer@blendedblue}#1\color{black}}
\newcommand{\synoder} {\ \ \color{black}$\vee$\ \ }
\newcommand{\hr} {\rule[4pt]{\textwidth}{0.1pt}\\}
\title{SSH-Tunnel}
\author{Ingo Blechschmidt \\\texttt{<iblech@web.de>}}
\institute{LUGA}
\date{8. Juni 2005}
\usetheme{Warsaw}
\usecolortheme{seahorse}
\setbeamercovered{transparent}
\begin{document}
\frame{\titlepage}
\section{Weiterleitung eines Ports}
\subsection{Problem und L"osungsidee}
\frame[t]{
\frametitle{Problem}
\begin{itemize}
\item Keine Möglichkeit der Verbindungsaufnahme zu Computern hinter einem
NAT-Gateway für außenstehende Computer
\pause
\item Err, keine NAT-Gateways bei IPv6
\item Problem gelöst, vielen Dank für die Aufmerksamkeit!
\end{itemize}
}
\frame[t]{
\frametitle{Inhalt}
\tableofcontents
}
\frame[t]{
\frametitle{Lösungsidee}
\begin{itemize}
\item Bei IPv4: Keine direkte Ansprechmöglichkeit von Computern hinter
einem NAT-Gateway wegen Fehlen von öffentlichen IP-Adressen
\item Lösung: SSH-Tunnel
\end{itemize}
\hfill\includegraphics[scale=0.38]{../Inhalte/Sonstiges/1337/LUGA/ssh-tunnel-1.png}
}
\subsection{Umsetzung}
\frame[t]{
\frametitle{Init-Skript}
\texttt{%
\syncomment{\#!/bin/sh}\\
\ \\
\synfunc{case}\ "\synvar{\$1}"\ \synfunc{in}\\
\ \ \synstr{start})\\
\only<1>{\ \ \ \ \synfunc{echo}\ -n "\synstr{Establishing SSH tunnels...}"\ >{}\&2\\
\ \ \ \ \synfunc{su}\ tunnel -c '\synstr{/home/tunnel/tunnel.sh 20000}' \&\\
\ \ \ \ \synfunc{su}\ tunnel -c '\synstr{/home/tunnel/tunnel.sh 20001}' \&\\
\ \ \ \ \synfunc{su}\ tunnel -c '\synstr{/home/tunnel/tunnel.sh 20002}' \&\\
\ \ \ \ \synfunc{echo}\ "\synstr{done.}"\ >{}\&2}%
\only<2->{\ \ \ \ \textit{[...]}}%
;;\\
\ \ \synstr{stop})\\
\only<2>{\ \ \ \ \synfunc{echo}\ -n "\synstr{Stopping SSH tunnels...}"\ >{}\&2\\
\ \ \ \ \synfunc{killall}\ \synstr{tunnel.sh}\ \ \ \ \ \ \ \ \syncomment{\# hacky}\\
\ \ \ \ \synfunc{sleep}\ 2\\
\ \ \ \ \synfunc{killall}\ -9 \synstr{tunnel.sh}\ \ \ \ \ \syncomment{\# hacky}\\
\ \ \ \ \synfunc{echo}\ "\synstr{done.}"\ >{}\&2}%
\only<1,3->{\ \ \ \ \textit{[...]}}%
;;\\
\ \ *)\\
\only<3>{\ \ \ \ \synfunc{echo}\ "\synstr{Usage: }\synvar{\$0}\synstr{\ start|stop}"\ >{}\&2\\
\ \ \ \ \synfunc{exit}\ 1}%
\only<1-2>{\ \ \ \ \textit{[...]}}%
;;\\
\synfunc{esac}\\
}
}
\frame[t]{
\frametitle{Konfiguration von SSH}
\only<1>{
\begin{itemize}
\item Keine Möglichkeit von Passworteingaben $\Rightarrow$ \\
SSH-Schlüssel zur Authentifizierung
\item Hinzufügen des neuen Schlüssels zur Liste erlaubter Keys auf dem
vermittelnden Server
\end{itemize}
}
\only<2>{
\begin{block}{Auf dem Rechner hinter dem NAT-Gateway}
\texttt{%
tunnel@hinter-nat \$ \textbf{\synfunc{ssh-keygen}\ -t dsa}\\
\scriptsize
Generating public/private dsa key pair.\\
Enter file in which to save the key (/home/tunnel/.ssh/id\_{}dsa): \\
Enter passphrase (empty for no passphrase): \\
Enter same passphrase again: \\
Your identification has been saved in /home/tunnel/.ssh/id\_{}dsa.\\
Your public key has been saved in /home/tunnel/.ssh/id\_{}dsa.pub.\\
The key fingerprint is:\\
45:ab:b7:8c:b6:b3:4b:76:3b:20:93:78:28:0c:61:25 tunnel@hinter-nat\\
}
\ \\
Wichtig: Keine Passphrase!
\end{block}
}
\only<3>{
\begin{block}{Auf dem vermittelnden Server}
\footnotesize
\texttt{%
tunnel@verm-server \$ \textbf{\synfunc{cat}\ >{}>{} \synstr{\~{}/.ssh/authorized\_{}keys}}\\
command="/home/tunnel/sleep.sh",\\
\ \ no-pty,\\
\ \ no-X11-forwarding,\\
\ \ no-agent-forwarding\\
\ \ \textnormal{[Inhalt von \texttt{hinter-nat:\~{}tunnel/.ssh/id\_{}dsa.pub}]}
}
\ \\\vspace{-3mm}
\begin{itemize}
\item \texttt{command="\textit{[...]}"}: \\
Nutzung des Accounts \textbf{nur} für's Tunneln, \textbf{kein}
Shell-Zugriff
\item \texttt{no-pty}: \\
Keine Alloziierung von Pseudo Terminals (Ressourcenschonung)
\item \texttt{no-X11-forwarding}, \texttt{no-agent-forwarding}: \\
Erneut: Nutzung ausschließlich für's Tunneln
\end{itemize}
\end{block}
}
}
\frame[t]{
\frametitle{\texttt{sleep.sh}}
\begin{itemize}
\item Verhindern von möglichen Problemen bei Nichtbenutzung des Tunnels
\item Alle fünf Minuten Ausgabe des aktuellen Datums $\Rightarrow$
\item SSH-Verbindung immer aktiv
\end{itemize}
\begin{block}{\texttt{verm-server:/home/tunnel/sleep.sh}}
\texttt{%
\synfunc{echo}\ -e "\synstr{This account may only be used for\\\ \ port forwarding.\textbackslash{}r}"\\
\ \\
\synfunc{while}\ \synfunc{:}; \synfunc{do}\\
\ \ \synfunc{sleep}\ 300\\
\ \ \synfunc{echo}\ -e "\`{}\synfunc{date}\`{}\synstr{: Still alive.\textbackslash{}r}"\\
\synfunc{done}\\
}
\end{block}
}
\frame[t]{
\frametitle{Kernskript}
\only<1>{
\begin{block}{\texttt{hinter-nat:/home/tunnel/tunnel.sh}}
\texttt{\small%
\syncomment{\#!/bin/sh}\\
\ \\
\symbol{91}\ "\synvar{\$1}"\ ] || \{\\
\ \ \synfunc{echo}\ "\synstr{Usage: }\synvar{\$0}\synstr{\ port}"\\
\ \ \synfunc{exit}\ 1\\
\}\\
\ \\
\synfunc{while}\ \synfunc{:}; \synfunc{do}\\
\ \ \synfunc{ssh}\ -T -R \synvar{\$1}\synstr{:localhost:22}\ \textbackslash{}\\
\ \ \ \ \synstr{tunnel@verm-server}\ '\synstr{/home/tunnel/sleep.sh}'\\
\ \ \synfunc{sleep}\ 30\\
\synfunc{done}\\
}
\end{block}
}
\only<2->{
\begin{itemize}
\item \texttt{\synfunc{ssh}\ -T}: \\
"`Danke, aber wir brauchen kein Pseudo Terminal."'
\item \texttt{\synfunc{ssh}\ -R \synvar{\$1}\synstr{:localhost:22}}: \\
Tunnel \texttt{\synstr{verm-server:}\synvar{\$1}} $\rightarrow$
\texttt{\synstr{localhost:22}}
\item \texttt{\synfunc{sleep}\ 30}: \\
Kein Flooding des Netzes, Schonung des Prozessors (ansonsten evtl.
ständiges Forken!)
\end{itemize}
}
}
\frame[t]{
\frametitle{Aktive Kontrolle}
\begin{block}{\texttt{hinter-nat:/home/tunnel/tunnel-check.sh}}
\texttt{%
\syncomment{\#!/bin/sh}\\
\ \\
\synfunc{nc}\ -z -w 20 \synstr{verm-server}\ 20000 || \{\\
\ \ \synfunc{sleep}\ 10\\
\ \ \synfunc{nc}\ -z -w 20 \synstr{verm-server}\ 20000 || \{\\
\ \ \ \ \synfunc{killall}\ \synstr{ssh}\ \ \ \ \ \ \ \ \ \ \syncomment{\# hacky!}\\
\ \ \ \ \synfunc{sleep}\ 2\\
\ \ \ \ \synfunc{killall}\ -9 \synstr{ssh}\ \ \ \ \ \ \ \syncomment{\# hacky!}\\
\ \ \}\\
\}\\
}
\end{block}
Start von \texttt{tunnel-check.sh} per Cron alle fünf Minuten
}
\section{Tunneln von ganzen Netzen}
\subsection{Problem und Lösungsidee}
\frame[t]{
\frametitle{Problem und Lösungsidee}
\begin{itemize}
\item Weiterleitung nur eines Ports ungenügend
\item Wunsch nach \textbf{transparenter} Weiterleitung ganzer Netze
\item Lösung: Point-to-Point Protocol Daemon (pppd)
\end{itemize}
\vfill
\begin{block}{Funktionsweise des pppd}
\begin{itemize}
\item Bereitstellen von einfacher Byte-Übertragung durch beliebige untere
Schicht ("`Modem"', "`ISDN"', "`Funk"', DNS (!), SSH)
\item Bereitstellen von IP durch die pppd auf beiden Seiten
\item Neues Interface: \texttt{ppp\textit{N}}
\end{itemize}
\end{block}
}
\frame{
\frametitle{Netzwerkdiagramm}
\begin{center}
\includegraphics[scale=0.45]{../Inhalte/Sonstiges/1337/LUGA/ssh-tunnel-2.png}
\end{center}
}
\subsection{Umsetzung}
\frame[t]{
\frametitle{Umsetzung}
\begin{itemize}
\item Simpel: Ersetzen des SSH-Aufrufs in \texttt{tunnel.sh} durch
\texttt{vpn-pppssh} von
\url{http://www.tldp.org/HOWTO/ppp-ssh/configclient.html\#AEN305}
\pause
\item (Fertig.)
\end{itemize}
}
\section{Ausstehende Probleme}
\frame[t]{
\frametitle{Ausstehende Probleme}
\begin{itemize}
\item Manuelle Eingriffe erforderlich zur Installation und
(Um-)Konfigurierung der Tunnel
\item (Kleiner) Overhead durch SSH und PPP (aber: Verschlüsselung!)
\item Trotzdem: Stabile Tunnel mit Neuaufbau möglich
\end{itemize}
\vfill\pause
\begin{block}{Einzige cleane Lösung}
\begin{itemize}
\item Einmalige Installation von IPv6 auf den Routern
\item \texttt{\# \textbf{modprobe ipv6}}
\item Fertig.
\end{itemize}
\end{block}
}
\end{document}
Download