$\renewcommand{\Re}{\operatorname{Re}}$
Characteristic equation:
$$
\left|\begin{matrix} 1-k & -2\\ 1 & -1-k \end{matrix}\right|= k^2+1=0\implies k_{1,2}=\pm i.
$$
Finding eigenvector corresponding to $k_1=i$
$$
\begin{pmatrix} 1-i & -2\\ 1 & -1-i \end{pmatrix}\begin{pmatrix} \alpha\\ \beta \end{pmatrix}=0\implies
\alpha =(1+i)\beta\implies \mathbf{e}_1 =\begin{pmatrix} 1+i\\ 1 \end{pmatrix}$$
and $\mathbf{e}_2$ is complex conjugate. Then the general solution to the homogeneous equation is
\begin{align}
\begin{pmatrix}x\\y\end{pmatrix}=&\Re \Bigl[(C_1+iC_2) (\cos (t)+i\sin(t))\begin{pmatrix} 1+i\\ 1 \end{pmatrix}\Bigr]\notag\implies \\
&x= C_1 (\cos(t)-\sin(t))+ C_2( -\cos(t)-\sin(t) )\\
&y= C_1\cos(t) -C_2\sin(t) \,.
\label{eq-4-1}
\end{align}
We are looking for solution to inhomogeneous equation in the same form albeit with variable $C_1,C_2$. Then
\begin{align*}
&\left\{\begin{aligned}
&C'_1 (\cos(t)-\sin(t))+ C'_2( -\cos(t)-\sin(t) )=\sec(t),\\
&C'_1\cos(t) \qquad\qquad -\ C'_2\sin(t) \qquad\qquad \quad=0
\end{aligned}\right.\implies\\[4pt]
&\left\{\begin{aligned}
&C'_1\sin(t)+ C'_2\cos(t)=-\sec(t),\\
&C'_1\cos(t) -\ C'_2\sin(t) =0
\end{aligned}\right.\implies\\
&\left\{\begin{aligned}
&C'_1= -\sec(t)\sin(t)=-\tan(t)\implies C_1=\ln (\cos(t))+c_1\\
&C'_2=-\sec(t)\cos(t)=-1\implies C_2=-t +c_2\,.
\end{aligned}\right.
\end{align*}
Finally
\begin{align*}
&x= [\ln (\cos(t))+c_1] (\cos(t)-\sin(t))+ [t -c_2]( \cos(t)+\sin(t) )\,\\
&y=[\ln (\cos(t))+c_1]\cos(t) +[t-c_2]\sin(t) \,.
\end{align*}