Skip to content

Instantly share code, notes, and snippets.

@masa-iwasaki
Created March 18, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masa-iwasaki/2564439555e2584387191eb525f06aec to your computer and use it in GitHub Desktop.
Save masa-iwasaki/2564439555e2584387191eb525f06aec to your computer and use it in GitHub Desktop.
Login GitHub Actions VM with SSH using Tailscale
name: Setup Tailscale on GitHub Actions
on: [push]
jobs:
tailscale:
runs-on: ubuntu-20.04
steps:
- run: |
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.gpg | sudo apt-key add -
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.list | sudo tee /etc/apt/sources.list.d/tailscale.list
- run: |
sudo apt-get update
sudo apt-get install tailscale
- run: |
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
echo "$SSH_PUBKEY" >> ~/.ssh/authorized_keys
chmod 755 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
env:
SSH_PUBKEY: ${{ secrets.SSH_PUBKEY }}
- run: |
echo "Setting up tailscale ..."
sudo tailscale up
echo -n "Done"
# Assume that `tailscale status` shows local IP in the first line of outputs
- run: |
HOST=`sudo tailscale status | head -n1 | tr -s ' ' | cut -d ' ' -f 1`
echo "ssh -i /path/to/your_key `whoami`@$HOST"
# If you have troubles with ssh, try watching auth.log
# - run: tail -f /var/log/auth.log
- run: |
sleep 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment