Configuring SSH Keys on a Fresh Ubuntu Server

Introduction

Sometimes the Ubuntu installer fails to import your SSH keys from GitHub, or you may simply choose to skip that step during installation. In either case, it's easy to add your public key afterward. Here are two quick methods: manually pasting the key or downloading it directly from your GitHub account.

Guide

Option 1: Paste the key manually

On the Ubuntu server:

mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys

Paste your public key into the file, save, then run:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Option 2: Download directly from GitHub

If your public key is already on GitHub, you can have the server fetch it:

mkdir -p ~/.ssh
curl https://github.com/YOUR_GITHUB_USERNAME.keys >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Note

Replace YOUR_GITHUB_USERNAME with your actual GitHub username.