This guide will walk you through setting up SSH keys for automated deployment from GitHub Actions to your Raspberry Pi via Tailscale.
GitHub Access Token (what you have):
- Used for authenticating to GitHub API
- Used for git operations (clone, push, pull)
- Works over HTTPS
SSH Key Pair (what we need):
- Used for secure shell access to servers
- A pair of files: private key (secret) + public key (can share)
- GitHub Actions will use this to SSH into your Pi
On your local machine (not the Pi), open a terminal and run:
# Generate a new SSH key specifically for deployments
ssh-keygen -t ed25519 -f ~/.ssh/act-deploy -C "act-github-deployment"When prompted:
- "Enter passphrase": Just press Enter (leave empty for automated deployment)
- "Enter same passphrase again": Press Enter again
This creates two files:
~/.ssh/act-deploy- Private key (keep secret!)~/.ssh/act-deploy.pub- Public key (safe to share)
Copy the public key to your Pi's authorized keys:
# Method 1: Automatic (recommended)
ssh-copy-id -i ~/.ssh/act-deploy.pub comon@pi4
# Method 2: Manual if ssh-copy-id doesn't work
cat ~/.ssh/act-deploy.pub | ssh comon@pi4 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"Verify the key works:
ssh -i ~/.ssh/act-deploy comon@pi4If you can log in without a password, it's working! Type exit to disconnect.
On your Raspberry Pi, find its Tailscale IP:
# SSH into your Pi
ssh comon@pi4
# Get Tailscale IP (usually starts with 100.x.x.x)
tailscale ip -4Save this IP address - you'll need it for GitHub secrets.
-
Copy the private key content:
# On your local machine cat ~/.ssh/act-deploy
Copy the entire output (including
-----BEGIN OPENSSH PRIVATE KEY-----and-----END OPENSSH PRIVATE KEY-----) -
Go to GitHub:
- Navigate to https://github.com/Comon-tech/ACT
- Click Settings β Secrets and variables β Actions
- Click New repository secret
-
Add these secrets:
Name Value Description PI_HOST100.x.x.xYour Pi's Tailscale IP from Step 4 PI_USERcomonYour username on the Pi PI_SSH_KEY[paste private key] The private key content from above TAILSCALE_AUTH_KEY[see below] Tailscale authentication key -
Get Tailscale Auth Key:
- Go to https://login.tailscale.com/admin/settings/keys
- Click Generate auth key
- Check: β Reusable and β Ephemeral
- Copy the key and add it as
TAILSCALE_AUTH_KEYsecret
After setting up all secrets, the next push to the main branch will trigger automatic deployment!
- β Private key never leaves your machine or GitHub's secure vault
- β Tailscale provides encrypted tunnel - no exposed SSH port
- β Keys are separate from your personal SSH keys
- β You can revoke keys anytime from GitHub or regenerate them
"Permission denied (publickey)"
# Make sure permissions are correct on Pi
ssh comon@pi4
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys"Host key verification failed"
# Add Pi's Tailscale IP to known hosts
ssh-keyscan -H 100.x.x.x >> ~/.ssh/known_hostsTest from GitHub Actions side
- Check GitHub Actions logs under "Actions" tab
- Look for SSH connection errors
- Verify Tailscale is connected during deployment