1

I'm trying to deploy all the content of the current git repository (including branch and commit) and deploy that to a remote server using rsync.

Now I have I gitlab-ci file that has the following content in it:

image: ubuntu:18.04

.init_development_ssh: &init_development_ssh |
    eval $(ssh-agent -s)
    mkdir -p ~/.ssh
    chmod 700 ~/.ssh
    [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
    ssh-add <(echo "$STAGING_PRIVATE_KEY")

.tag: &tag
  tags:
    - pixel-rp

stages:
  - lint
  - deploy

linting code:
  # Use the LUA image
  image: mhndev/docker-lua
  <<: *tag
  stage: lint
  before_script:
    - luarocks install luacheck
  script: luacheck fx-server-data
  allow_failure: true

deploy to testing:
  <<: *tag
  stage: deploy
  before_script:
    - apt -y update && apt -y upgrade && apt install -y openssh-client rsync sshpass
    - *init_development_ssh
  script:
    - sshpass -p "$SSH_PASS" -e "ssh -p 2222" rsync -rav --exclude='.git/' --exclude='.gitlab-ci.yml' --delete-excluded /builds/pixel-rp/pixel-server/ user@IP:/home/user/FXServer/server-data/

The error I get is

> Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
    -f filename   Take password to use from file
    -d number     Use number as file descriptor for getting password
    -p password   Provide password as argument (security unwise)
    -e            Password is passed as env-var "SSHPASS"
    With no parameters - password will be taken from stdin
    -P prompt     Which string should sshpass search for to detect a password prompt
    -v            Be verbose about what you're doing
    -h            Show help (this screen)
    -V            Print version information
 At most one of -f, -d, -p or -e should be used
 Conflicting password source

Now I'm not a linux expert, but the parameters that are "required" to keep in mind are the following:

  • SSH port: 2222
  • SSH key is (as far as I know) successfully imported

Anyone who knows how I can take all the content (exclude some files) and "push" that to my remote server as "continious delivery"?

7
  • 1
    To me -p and -e seems mutually exclusive. Can you run the command manually? does it work then? Commented Feb 5, 2020 at 11:28
  • I haven't tried it manually tho, but what do you mean with -p and -e tags seem mutually? Commented Feb 5, 2020 at 12:45
  • From the usage screen you were presented it clearly states that At most one of -f, -d, -p or -e should be used. You define both -p and -e. Commented Feb 5, 2020 at 13:22
  • @fredrik I removed the -e option and get the following error:` sshpass: Failed to run command: No such file or directory` Commented Feb 5, 2020 at 13:49
  • Which indicates that sshpass is not installed on the node that's running the job. Commented Feb 5, 2020 at 14:15

1 Answer 1

1

According to the manpage of sshpass, you can specify the password in the command line using the option -p and tell sshpass to use the password from the environment variable SSHPASS when using the option -e.

As you can only specify the password once but you used both options, sshpass does not know where to take the password from (from the command line or the environment variable) and therefor fails.

The options -f (to read from a file) and -d (to read from a file descriptor) also can't be used in combination with any of the other options.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.