ssh-action icon indicating copy to clipboard operation
ssh-action copied to clipboard

ProxyCommand Cloudflare example

Open RuslanZavacky opened this issue 3 years ago • 1 comments

I see that ProxyCommand is available, but can't figure out how to correct specify it like to connect via Cloudflared agent. For example, in Cloudflare, .ssh/config looks like this:

Host jump.something.dev
  ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h --id <myid> --secret <mysecret>
  ServerAliveInterval 30
  ServerAliveCountMax 5

How I can specify that in yaml?

Thank you in advance!

RuslanZavacky avatar Sep 06 '21 12:09 RuslanZavacky

I was looking for it, end up with following solution.

name: api-deployment

on:
  push:
    branches:
      - master

jobs:
  deployment:
    runs-on: ubuntu-latest
    steps:
      - name: check out
        uses: actions/checkout@master
      - name: install cloudflared
        run: |
          curl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-archive-keyring.gpg >/dev/null
          echo "deb [signed-by=/usr/share/keyrings/cloudflare-archive-keyring.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" | sudo tee  /etc/apt/sources.list.d/cloudflared.list
          sudo apt update
          sudo apt-get install cloudflared
          cloudflared --version
      - name: install-ssh-key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          name: id_rsa
          known_hosts: ${{ secrets.KNOWN_HOSTS }}
          if_key_exists: fail
      - name: deploy api
        run:
          ssh  -o ProxyCommand="cloudflared access ssh --hostname <host>" pi@<host> < ./scripts/deploy_api.sh

metrue avatar Jan 02 '23 12:01 metrue