% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math} % this also loads fontspec
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
  % xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
\hypersetup{
  pdftitle={public-and-private-ssh-keys},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}

\title{public-and-private-ssh-keys}
\author{}
\date{}

\begin{document}
\maketitle

\hypertarget{public-and-private-ssh-keys}{%
\section{public-and-private-ssh-keys}\label{public-and-private-ssh-keys}}

Public and Private SSH Keys
\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#

I tend to think of:

\begin{itemize}
\tightlist
\item
  a server host as a ``house''
\item
  a public key as a ``lock'' on a door of a ``house''
\item
  a private key as a ``key'' to the ``lock'' on a door of a ``house''
\end{itemize}

In this way, anyone might have access to the outside of a ``house''.
Anyone could have access to the ``lock'' on a house. Only you should
have access to the private ``key''.

\hypertarget{how-to-create-a-new-public-and-private-ssh-keypair}{%
\section{How to create a new public and private ssh
keypair}\label{how-to-create-a-new-public-and-private-ssh-keypair}}

Create a ssh public/private keypair:

.. code-block:: bash

ssh-keygen -t rsa -b 4096 \#enter a passphrase when asked

Document the passphrase in keypass

\hypertarget{how-to-add-the-public-key-to-a-host}{%
\section{How to add the public key to a
host}\label{how-to-add-the-public-key-to-a-host}}

Append the contents of .pub key to a remote host's
\textasciitilde/.ssh/authorized\_keys. The user's
\emph{authorized\_keys} file may contain none or many keys.

.. note::

The \emph{authorized\_keys} file must be mode 400

The \emph{.ssh} directory must be mode 700

\hypertarget{how-to-add-a-private-key-to-your-workstation}{%
\section{How to add a private key to your
workstation}\label{how-to-add-a-private-key-to-your-workstation}}

Keep all your private keys in the same directory with the .key
extension. Use the following script to add all private .key files to ssh
agent:

.. code-block:: bash

for f in *.key; do ssh-add \$f; done

The SSH agent will prompt for each key's passphrase in turn. This must
be done after each reboot.

\hypertarget{could-not-open-a-connection-to-your-authentication-agent}{%
\subsection{Could not open a connection to your authentication
agent}\label{could-not-open-a-connection-to-your-authentication-agent}}

You must have a running ssh-agent and your shell must have access to use
it. If you get this error message when you attempt to run ssh-add then
first run the following command to spawn an ssh-agent for this shell:

.. code-block:: bash

eval ``\$(ssh-agent)''

Now try to run ssh-add again.

Another command for debugging:

.. code-block:: bash

echo \$SSH\_AUTH\_SOCK

\hypertarget{how-to-create-a-putty-ppk}{%
\section{How to create a putty ppk}\label{how-to-create-a-putty-ppk}}

\begin{enumerate}
\item
  Create a keypair:
  \texttt{How\ to\ create\ a\ new\ public\ and\ private\ ssh\ keypair}\_
\item
  SCP the keypair from unix host to windows host
\item
  Download and open puttygen.exe

  \begin{itemize}
  \tightlist
  \item
    Click the \emph{Load} button
  \item
    Browse to the private key, might need to choose `All Files(*.*)'
    from dropdown
  \item
    enter passphrase, click \emph{OK}
  \item
    Click the \emph{Save private key} bytton
  \item
    Name the new key with .ppk extension, and hit \emph{Save}
  \end{itemize}
\item
  Add the .ppk to putty.exe and test
\end{enumerate}

\end{document}
