Secure Shell (SSH)

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. SSH provides encrypted remote access.

SSH Basics

Check All SSH Keys

ls ~/.ssh

Create a New SSH Private & Public Key

This command creates both a private and a public key as a pair. Keep the private key secret, and share the public key.

ssh-keygen -t ed25519 -C "your-email@example.com"

# This creates two keys:
# - id_ed25519 (private)
# - id_ed25519.pub (public)

Add Private Key to SSH Auth Agent

This command tells your system to load a private SSH key into the SSH authentication agent. This makes the key available for SSH connections, and lets you authenticate without retyping the passphrase every time.

ssh-add ~/.ssh/id_ed25519_fc

Copy the Public Key Somewhere

You can copy the public key somewhere like GitHub to enable remote access.

cat ~/.ssh/id_ed25519.pub

Creating Aliases in the Config File

nano ~/.ssh/config

SSH & GitHub

Test SSH Connection to GitHub

ssh -T git@github.com

# Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Testing SSH w/ Specific Keys

# Use one SSH key

ssh -i ~/.ssh/id_rsa -T git@github.com
# Use another SSH key

ssh -i ~/.ssh/id_ed25519 -T git@github.com

Running Commands w/ Specific Keys

These commands let you run commands using specific keys.

GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519" \
git clone git@github.com:Organization/Project.git
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519" \
git push -u origin feat/add_static_outage_page