Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEY and PUBKEY not getting passed properly. #79

Closed
nrutman opened this issue May 28, 2020 · 8 comments
Closed

KEY and PUBKEY not getting passed properly. #79

nrutman opened this issue May 28, 2020 · 8 comments

Comments

@nrutman
Copy link

nrutman commented May 28, 2020

Bug Description
I'm trying to use SFTP with private/public keys via the key and pubkey options to git-ftp. However, it seems to pass something unrecognized by git-ftp which then flags my server connection string as an "unrecognised option" (see the logs below and this comment which links states that git-ftp uses the first unknown option as the URL and then flags the URL as the unrecognized option).

If I delete the remote directory, take out the key and pubkey options, and instead pass insecure, the whole repo uploads…but the whole repo uploads EVERY time. It writes the SHA but cannot read it (Unknown SHA1 object, could not determine changed files, taking all files.).

I've tried to replicate git-ftp command locally (just plugging in all the variables) and everything worked fine. It read the SHA and properly uploaded only what had changed. I then realized that my local version of git-ftp was 1.6.0, not 1.5.1 (which is what the action is using). Could that be the problem?

Any light you can shed on what I'm doing wrong would be really helpful.

My Action Config

name: Deploy Code

on:
  push:
    branches:
      - master
      - ci

jobs:
  FTP-Deploy:
    name: FTP Deploy
    runs-on: ubuntu-latest
    steps:
      - name: Store SSH Keys
        run: |
          mkdir -p ~/.ssh/
          echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa_deploy
          echo "$SSH_PUBLIC_KEY" > ~/.ssh/id_rsa_deploy.pub
          sudo chmod 600 ~/.ssh/id_rsa_deploy
          sudo chmod 600 ~/.ssh/id_rsa_deploy.pub
          ssh-keyscan -H "$HOST" > ~/.ssh/known_hosts
        shell: bash
        env:
          SSH_PRIVATE_KEY: ${{ secrets.key_private }}
          SSH_PUBLIC_KEY: ${{ secrets.key_public }}
          HOST: ${{ secrets.ssh_server }}

      - name: Checkout Code
        uses: actions/[email protected]

      - name: FTP Deploy
        uses: SamKirkland/[email protected]
        with:
          ftp-server: sftp://${{ secrets.ssh_server }}:${{ secrets.ssh_port }}/${{ secrets.remote_path }}
          ftp-username: ${{ secrets.ssh_user }}
          ftp-password: ${{ secrets.ssh_password }}
          known-hosts: ${{ secrets.ssh_knownhosts }}
          git-ftp-args: --key "~/.ssh/id_rsa_deploy" --pubkey "~/.ssh/id_rsa_deploy.pub"

      - name: Install Dependencies
        run: |
          ssh -i ~/.ssh/id_rsa_deploy -p "$SSH_PORT" "$SSH_HOST" "cd $REMOTE_PATH && $COMPOSER_BIN install"
        shell: bash
        env:
          SSH_PORT: ${{ secrets.ssh_port }}
          SSH_HOST: ${{ secrets.ssh_user }}@${{secrets.ssh_server}}
          REMOTE_PATH: ${{ secrets.remote_path }}
          COMPOSER_BIN: ${{ secrets.composer_bin }}

My Action Log (relevant section)

2020-05-28T01:33:45.5647508Z ##[warning]Unexpected input 'known-hosts', valid inputs are ['entryPoint', 'args', 'ftp-server', 'ftp-username', 'ftp-password', 'local-dir', 'git-ftp-args']
2020-05-28T01:33:45.5664085Z ##[group]Run SamKirkland/[email protected]
2020-05-28T01:33:45.5664523Z with:
2020-05-28T01:33:45.5665420Z   ftp-server: sftp://***:***/***
2020-05-28T01:33:45.5665865Z   ftp-username: ***
2020-05-28T01:33:45.5666448Z   ftp-password: ***
2020-05-28T01:33:45.5667286Z   known-hosts: ***
2020-05-28T01:33:45.5667751Z   git-ftp-args: --key "~/.ssh/id_rsa_deploy" --pubkey "~/.ssh/id_rsa_deploy.pub"
2020-05-28T01:33:45.5668250Z   local-dir: ./
2020-05-28T01:33:45.5668668Z ##[endgroup]
2020-05-28T01:33:45.5695711Z ##[command]/usr/bin/docker run --name d3422175328c6f48168a6d3fedeb7f4fee_4c8410 --label 3888d3 --workdir /github/workspace --rm -e INPUT_FTP-SERVER -e INPUT_FTP-USERNAME -e INPUT_FTP-PASSWORD -e INPUT_KNOWN-HOSTS -e INPUT_GIT-FTP-ARGS -e INPUT_LOCAL-DIR -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_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -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/redemption-stories/redemption-stories":"/github/workspace" 3888d3:422175328c6f48168a6d3fedeb7f4fee
2020-05-28T01:33:46.5518960Z [command]/bin/mkdir -v -p /github/home/.ssh
2020-05-28T01:33:46.5578985Z /bin/mkdir: created directory '/github/home/.ssh'
2020-05-28T01:33:46.5620727Z [command]/bin/chmod 700 /github/home/.ssh
2020-05-28T01:33:46.5675770Z [command]/bin/chmod 755 /github/home/.ssh/known_hosts
2020-05-28T01:33:46.5702113Z ✅ Configured known_hosts
2020-05-28T01:33:46.5712051Z ##[group]Uploading files
2020-05-28T01:33:46.5725771Z [command]/usr/bin/git ftp push --force --auto-init --verbose --syncroot=./ --user=*** --passwd=*** --key "~/.ssh/id_rsa_deploy" --pubkey "~/.ssh/id_rsa_deploy.pub" sftp://***:***/***
2020-05-28T01:33:46.5874474Z Thu May 28 01:33:46 UTC 2020: git-ftp version 1.5.1 running on Linux 315bf7ab2a87 5.3.0-1020-azure #21~18.04.1-Ubuntu SMP Wed Apr 15 09:35:56 UTC 2020 x86_64 GNU/Linux
2020-05-28T01:33:46.5875231Z Thu May 28 01:33:46 UTC 2020: Forced mode enabled.
2020-05-28T01:33:46.5875823Z Thu May 28 01:33:46 UTC 2020: Auto init if needed.
2020-05-28T01:33:46.5906704Z Thu May 28 01:33:46 UTC 2020: Using syncroot ./ if exists.
2020-05-28T01:33:46.5939063Z Thu May 28 01:33:46 UTC 2020: fatal: Unrecognised option: sftp://***:***/***
2020-05-28T01:33:46.5965375Z ##[endgroup]
2020-05-28T01:33:46.5967482Z ##[error]The process '/usr/bin/git' failed with exit code 3
2020-05-28T01:33:46.5970058Z ✅ Deploy Complete
@SamKirkland
Copy link
Owner

Thanks for spending so much time looking into this before posting.
Interesting the debian package is out of date. I'll look into getting that fixed.

I have run into similar issues when arguments have a space. git-ftp does no escaping so users who have username/passwords with a space are treated as two arguments.

@nrutman
Copy link
Author

nrutman commented May 28, 2020

Hmm...neither my username nor password have spaces. The username is an email address, and the password does have a ! in it, which I've found in my shell needs to be escaped or it gets confused by some sort of replacement character. Maybe I'll try escaping that and see what happens.

@yahsan2
Copy link

yahsan2 commented Jun 3, 2020

I have the same issue.

I checked git-ftp command on my local environment.

This command without = is not working.
git ftp push -vv --key ./id_rsa --force --auto-init --verbose --syncroot=./ --user=me --passwd=mypass sftp://myhost/mypath
But this command with = is not working and I got the same error message.
git ftp push -vv --key=./id_rsa --force --auto-init --verbose --syncroot=./ --user=me --passwd=mypass sftp://myhost/mypath

@yahsan2
Copy link

yahsan2 commented Jun 3, 2020

But I got same error on github actions. :(

  /usr/bin/git ftp push --force --auto-init --verbose --syncroot=./ --user=*** --passwd=*** --key ./id_rsa ***
  Wed Jun  3 00:59:50 UTC 2020: git-ftp version 1.5.1 running on Linux 1bf895a903c9 5.3.0-1020-azure #21~18.04.1-Ubuntu SMP Wed Apr 15 09:35:56 UTC 2020 x86_64 GNU/Linux
  Wed Jun  3 00:59:50 UTC 2020: Forced mode enabled.
  Wed Jun  3 00:59:50 UTC 2020: Auto init if needed.
  Wed Jun  3 00:59:50 UTC 2020: Using syncroot ./ if exists.
  Wed Jun  3 00:59:50 UTC 2020: fatal: Unrecognised option: ***
##[error]The process '/usr/bin/git' failed with exit code 3

@pgcath
Copy link

pgcath commented Jun 4, 2020

I am interested in this workflow as well, for deploying to AWS LightSail.

Is there an example of "best practice" for using SFTP with public and private keys?

@alancwoo
Copy link

alancwoo commented Jul 6, 2020

Unfortunately running into this issue as well, trying to use ssh key authentication.

/usr/bin/git ftp push --force --auto-init --verbose --syncroot=./ --user=REDACTED --passwd=REDACTED --key "~/.ssh/id_rsa_deploy" --dry-run sftp://***:***/var/www
...
fatal: Unrecognised option: sftp://***:***/var/www

My actions yml has the ftp-server set explicitly as plaintext as sftp://hostname:port/path, so I'm not sure what's going on.

I'm using SamKirkland/[email protected]

@PascalHessler
Copy link

Yes I also ran into the exact same mistake. Is there a solution/workaround?

@SamKirkland SamKirkland mentioned this issue Nov 13, 2020
9 tasks
@SamKirkland
Copy link
Owner

version 4 resolves this. Please upgrade to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants