Reputation: 17556
I have a shell script that can connect to my server. It executes some shell commands there. Now I want to integrate the script into my GitHub action workflow. I have put the script in my repository and the script is also started. But I don't have any ssh commands yet, only echo commands in the script. Therefore it runs successfully.
Now I want to add the SSH commands to the script. But I wonder how I should handle the SSH key now. As I understand it, GitHub does not have a private key from which I can generate my public key and then store it on the server.
Upvotes: 1
Views: 4372
Reputation: 1323753
You might consider using the GitHub Action appleboy/ssh-action
Executing remote ssh commands.
name: remote ssh command
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: whoami
You can register your private key and other sensitive data as GitHub secret for your repository.
Upvotes: 2