\documentclass[11pt]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xspace}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{xifthen}
\usepackage[a4paper,lmargin={2cm},rmargin={2cm},tmargin={2.5cm},bmargin = {2.5cm},headheight = {4cm}]{geometry}
\usepackage{amsmath,amssymb,amstext,amsthm}
\usepackage[shortlabels]{enumitem}
\usepackage[headsepline]{scrlayer-scrpage} 
\pagestyle{scrheadings} 
\usepackage{titling}
\usepackage{etoolbox}
\usepackage{tikz}

\usetikzlibrary{shapes, arrows, calc, automata, arrows.meta, positioning,decorations.pathmorphing,backgrounds,decorations.markings,decorations.pathreplacing, graphs}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains, calc}

\tikzset{% 
    initial text={},
    state/.style={circle, draw, minimum size=.6cm},
    every initial by arrow/.style={-stealth},
    every loop/.append style={-stealth},
    >=stealth
}

\ohead{\parbox[t]{.5\linewidth}{\raggedleft \theauthor}}
\ihead{System Security, SoSe 24, Assignment \thesheetnr}

% Sheet number
\newcounter{sheetnr}
\newcommand{\sheetnr}[1]{\setcounter{sheetnr}{#1}}

% Exercise environments
\newenvironment{exercise}[2][]{\section*{#2\expandafter\ifstrempty\expandafter{#1}{}{\ #1}}}{}
\newenvironment{subexercises}{\begin{enumerate}[a), font=\bfseries, wide, labelindent=0pt]}{\end{enumerate}}
\newenvironment{subsubexercises}{\begin{enumerate}[i), font=\bfseries, wide, labelindent=0pt]}{\end{enumerate}}

% Makros

% Anpassen --> %
\author{Benjamin Haschka\\Sascha Tommasone\\Paul Zinselmeyer}
\sheetnr{4}
% <-- Anpassen %

\begin{document}
\begin{exercise}[Warm Up]{2.1.}

\end{exercise}

\newpage
\begin{exercise}[Key Establishment]{2.2.}

\end{exercise}

\newpage
\begin{exercise}[Authentication without Trusted Party]{2.3.}

\end{exercise}

\newpage
\begin{exercise}[Authentication with Trusted Party]{2.4.}

\end{exercise}
\end{document}