Issue
I'm using appleboy/ssh-action@master
, I set up a github action that tries to pull changes on my server after a push to github.
name: Deploy to VPS
on:
push:
branches: [master, dev]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy App
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
password: ${{ secrets.PASS }}
script: |
cd myfolder
git pull
I've used password authentication above, I also used ssh authentication with key: ${{ secrets.SSHKEY }}
instead of a password.
Both the above throw me an error :
Run appleboy/[email protected]
/usr/bin/docker run --name 645231_39754c --label 48c8ce --workdir /github/workspace --rm -e INPUT_HOST -e INPUT_USERNAME -e INPUT_PORT -e INPUT_PASSWORD -e INPUT_SCRIPT -e INPUT_PASSPHRASE -e INPUT_SYNC -e INPUT_USE_INSECURE_CIPHER -e INPUT_CIPHER -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY -e INPUT_KEY_PATH -e INPUT_FINGERPRINT -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_PROXY_FINGERPRINT -e INPUT_PROXY_CIPHER -e INPUT_PROXY_USE_INSECURE_CIPHER -e INPUT_SCRIPT_STOP -e INPUT_ENVS -e INPUT_DEBUG -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/myproject/myproject":"/github/workspace" 48c8ce:9865421398654
======CMD======
cd myproject
git pull
======END======
2021/08/15 21:58:52 Process exited with status 1
err: fatal: could not read Username for 'https://github.com': No such device or address
What am I doing wrong?
Solution
The appleboy/ssh-action
is supposed to use as parameter a host
to contact, using the ssh key or a login/passord.
But once the connection is established, the commands done depends on the remote environment: if that git repository on the SSH-accessed remote machine has an HTTPS URL, no SSH key will be used.
Even if it has an SSH key, that still would not use any key from the ssh-action plugin.
It would use the ~remoteUser/.ssh/id_rsa
default key already stored on the remote server home account.
If that key is there, to allow access to the remote GitHub private repository, then you need to change its origin to use the SSH URL:
script: |
cd myfolder
git remote set-url origin [email protected]:<user>/<repo>
# or, alternatively
git config --global url."[email protected]:".insteadOf https://github.com/
git pull
Answered By - VonC