DarkFenix
DarkFenix

Reputation: 746

It is possible to use Personal access tokens in ssh for a ci github actions?

I have a query, how can I use a personal access token for continuous integration with github actions

name: Integration

on:
  push:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: oleksiyrudenko/gha-git-credentials@v2-latest
      with:
        token: '${{ secrets.SECRET_GITHUB }}'
    - uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        password: ${{ secrets.PASSWORD }}
        port: ${{ secrets.PORT }}
        script: |
            cd /home/....
            git fetch --all
            git reset --hard origin/master

I have the following, but it doesn't update the repository on my production server. I would like to be able to use the username and the acces token as variable without globally setting the credentials on my server. it's possible?

Upvotes: 3

Views: 788

Answers (1)

VonC
VonC

Reputation: 1328112

Just to be clear, a GitHub Action for executing remote ssh commands would not use a token as password.

That token is only use for HTTPS URL, not SSH ones.
Using an ssh password is only when the key is not valid (ie, the public key was not published to the remote machine ~remoteUser/.ssh/authorized_keys), and acts as a fallback mechanism.

In your case, start with a private SSH key, without passphrase, for testing.

Upvotes: 1

Related Questions