liveBook · Manning

SSH key

As explained in Road to Kubernetes

An SSH key is a cryptographic key pair consisting of a private key and a corresponding public key for authenticating secure shell connections.

An SSH key is a cryptographic key pair: a private key and its corresponding public key. Together with a remote host, username, network connection, and SSH client, the pair supports secure-shell authentication without relying on a password. section 3.1.2 section 4.1.2

Use the two files for different purposes:

  • Keep the private key secret; store it as a GitHub Actions secret when automation needs it. section 4.1.2
  • Install the public key on the remote machine or provision it on new instances. section 4.1.2
  • Create a purpose-built pair for automation instead of exposing a personal key such as ~/.ssh/id_rsa. section 4.1.2
  • Ensure the required keys exist on both the machine running Ansible and the machines it configures. section 4.2

Create a dedicated automation key pair

Run ssh-keygen -t rsa -b 4096 -f github_actions_key -N "". This creates github_actions_key as the private key and github_actions_key.pub as the public key. Add the private file to a repository secret named SSH_PRIVATE_KEY, and install the public file on the remote instance. section 4.1.2

How Road to Kubernetes covers it

How deep it goes
Defines the private/public split and demonstrates generation, secret storage, instance installation, and Ansible prerequisites.
Examples
Uses ssh-keygen, github_actions_key files, the SSH_PRIVATE_KEY repository secret, and an Akamai Linode instance.
What it assumes
Assumes a remote host, username, network connection, and SSH client, while introducing key-based authentication alongside passwords.
What you can do after
Operate secure automated access by generating a pair, protecting its private file, and installing its public counterpart.
How it connects
Connects SSH authentication with remote hosts, GitHub Actions secrets, virtual machines, Ansible, and infrastructure automation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.