ssh
SSH into Server with Tailscale
Learn how to securely SSH into your servers during CI/CD workflows using Tailscale
1 min read
Step 1: Generate a Tailscale Auth Key
- Go to your Tailscale admin console.
- Navigate to Settings -> Keys -> Create Key.
- Choose the type:
- Reusable: Can be used multiple times (good for CI/CD).
- Ephemeral: Single-use key (more secure for temporary access).
- Copy the generated key and store it in GitHub Secrets as
TAILSCALE_AUTH_KEY.
Step 2: Prepare SSH Credentials
- On your server, ensure your public key is in
~/.ssh/authorized_keys. - Store your private key in GitHub Secrets as
SSH_PRIVATE_KEY. - Store your server username in GitHub Secrets as
SSH_USERNAME. - Store your Tailscale Server IP address in GitHub Secrets as
TAILSCALE_SERVER_IP.
Step 3: GitHub Actions Workflow
name: SSH to Tailscale Server
on:
push:
branches:
- main
jobs:
ssh-server:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Tailscale
run: |
curl -fsSL https://tailscale.com/install.sh | sh
- name: Connect to Tailscale
run: |
sudo tailscale up --authkey ${{ secrets.TAILSCALE_AUTH_KEY }}
- name: Test Tailscale connection
run: |
tailscale status
ping -c 3 ${{ secrets.TAILSCALE_SERVER_IP }}
- name: SSH into Tailscale Server
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{ secrets.TAILSCALE_SERVER_IP }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
whoami
hostname
hostname -I