90 lines
4.0 KiB
TeX
Executable File
90 lines
4.0 KiB
TeX
Executable File
\section{2 Factor authentication}
|
|
\subsection{Install}
|
|
\begin{justify}
|
|
F"ur SSH z.B. kann man eine zwei Factor Authentifizierung einrichten. Hierzu wird das Paket\\
|
|
{\ttfamily libpam-google-authenticator} installiert.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Installation]
|
|
uws@tux># Arch Linux
|
|
uws@tux>sudo pacman -S libpam-google-authenticator
|
|
|
|
uws@tux># Debian
|
|
uws@tux>sudo apt install libpam-google-authenticator
|
|
\end{lstlisting}
|
|
%--------------------------------------------------------------------------------
|
|
% Subsection: Konfiguration
|
|
%--------------------------------------------------------------------------------
|
|
\subsection{Konfiguration}
|
|
In der Datei {\ttfamily /etc/pam.d/sshd} wird in der ersten Zeile folgendes eingetragen.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Datei sshd]
|
|
uws@tux>grep -i "google" /etc/pam.d/sshd
|
|
auth required pam_google_authenticator.so
|
|
\end{lstlisting}
|
|
In der datei {\ttfamily /etc/ssh/sshd\verb|_|config} wird der Parameter {\ttfamily ChallengeResponseAuthentication} auf yes gesetzt.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Datei sshd\_config]
|
|
uws@tux>grep -i "ChallengeResponse" /etc/ssh/sshd_config
|
|
ChallengeResponseAuthentication yes
|
|
\end{lstlisting}
|
|
%--------------------------------------------------------------------------------
|
|
% Subsection: Key nicht für local
|
|
%--------------------------------------------------------------------------------
|
|
\subsection{Konfiguration outside}
|
|
Möchte man nur die Key-Abfrage haben, wenn man von au{ss}erhalb des lokalen Netzwerkes eine SSH Verbindung aufbaut, so ist folgendes zu machen.\\
|
|
In dem Verzeichnis /etc/seurity wird eine Datei mit dem Namen access-local.conf mit folgendem Inhalt erstellt.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Datei access-local.conf]
|
|
uws@tux>cat /etc/security/access-local.conf
|
|
# only allow from local IP range
|
|
+ : ALL : 192.168.70.0/24
|
|
# Anderes Netzwerk: VPN
|
|
+ : ALL : 10.81.10.0/24
|
|
+ : ALL : LOCAL
|
|
# Denied
|
|
- : ALL : ALL
|
|
\end{lstlisting}
|
|
In der Datei sshd im Verzeichnis /etc/pam.d wird zusätzlich vor der Zeile mit pam\verb|_|google folgende Zeile eingefügt.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Zeile einfügen]
|
|
uws@tux>grep -i -E "success|google" /etc/pam.d/sshd
|
|
auth [success=1 default=ignore] pam_access.so accessfile=/etc/security/access-local.conf
|
|
auth required pam_google_authenticator.so
|
|
\end{lstlisting}
|
|
%--------------------------------------------------------------------------------
|
|
% Subsection: Key-Datei erstellen
|
|
%--------------------------------------------------------------------------------
|
|
\subsection{Key-Datei erstellen}
|
|
Nun wird zum Abschlu"s der Secret Key File erstellt. Hierzu installiert man vorher {\ttfamily qreator} oder auch {\ttfamily qrencode}, um ein QR Code zu generieren. Für jeden User, der sich mit dem Computer verbinden möchte, muss eine Key-Datei mittels google-authenticator erstellt werden.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Secret Key File]
|
|
uws@tux>sudo pacman -S [qreator] [qrencode]
|
|
|
|
uws@tux>google-authenticator
|
|
.... Y
|
|
Your new secret key is: xxxxxxxxx...
|
|
Enter code from app (-1 to skip):
|
|
Code confirmed
|
|
Your emergeny scratch codes are:
|
|
|
|
.... Y
|
|
.... Y
|
|
.... N
|
|
.... Y
|
|
\end{lstlisting}
|
|
%--------------------------------------------------------------------------------
|
|
% Subsection: Dienst neu starten
|
|
%--------------------------------------------------------------------------------
|
|
\subsection{Dienst neu starten}
|
|
Nach erfolgter Konfiguration muss der sshd Dienst neu gestartet werden.
|
|
\listBash
|
|
\begin{lstlisting}[captionpos=b, caption=Secret Key File]
|
|
uws@tux>sudo systemctl restart sshd.service
|
|
\end{lstlisting}
|
|
%--------------------------------------------------------------------------------
|
|
% Subsection: TAN Generator
|
|
%--------------------------------------------------------------------------------
|
|
\subsection{Generator}
|
|
Auf dem Smartphone kann nun {\ttfamily FreeOtp} installiert werden, um dann den QR Code zu scannen. Es wird automatisch die Daten f"ur die Verbindung erstellt.
|
|
\end{justify}
|