Using GitHub Workflows to upload (SSH)

This isn’t Rails-related or even Ruby-related, but I’m sure that at least one person in this group has experience with this.

I have a script that can automatically upload files to SourceForge. This requires pre-authentication, and this is done through SSH keys. The authentication procedure consists of these two steps:

  1. Generate a key through SSH on my local machine. (SourceForge Support / Documentation / SSH Keys)
  2. Paste the public key contents in my SSH settings on Sourceforge. (SourceForge Support / Documentation / SSH Keys)

What I’m trying to do is replace my local machine with GitHub Workflows. My questions:

  1. How do I generate my keys through SSH in GitHub Workflows?
  2. How do I view my public key in GitHub Workflows so that I can paste it in my SSH settings on SourceForge?

Hey @jhsu802701,

I recently did this!

  1. Store your key in that repository as an action secret. Settings → Secrets → Actions.
  2. Do a keyscan for the host that you’ll be connecting to and store that as an Action secret as well, I saved it in KNOWN_HOSTS for that repo. ssh-keyscan -H github.com for example.
  3. Add something similar to this right before you’re going to connect via SSH in your github workflow.
    - name: Install SSH key
      uses: shimataro/ssh-key-action@v2
      with:
        key: ${{ secrets.SSH_KEY }}
        known_hosts: ${{ secrets.KNOWN_HOSTS }}
2 Likes

Thanks, Nick! I finally have things figured out, though my solution is slightly different. Check out what I did at GitHub - swiftlinux/remaster-mx21 .

I realize now that I had no clue how to use the secrets in GitHub Workflows. Now I understand.

Nice, glad that worked out for ya!