kestra-io / plugin-fs

https://kestra.io/plugins/plugin-fs/
Apache License 2.0
6 stars 7 forks source link

Secret not work as password in io.kestra.plugin.fs.ssh.Command #156

Closed pomazanbohdan closed 2 weeks ago

pomazanbohdan commented 1 month ago

Describe the issue

If you write the password without a secret, the flow works, if you write it with a secret, it doesn't.

id: com.fprofitable-erp.chocolate-pull
namespace: evo.lab
description: ""

tasks:
  - id: command
    type: io.kestra.plugin.fs.ssh.Command
    authMethod: PASSWORD
    commands:
      - cd odoo/odoo_com_profi_chocolate/odoo_addons_17_nonfree/
      - git pull
    host: 204.12.YYY.XXX
    password: "{{ secret('SERVER_A') }}"
    username: administrator
disabled: false

.env_encoded: SECRET_SERVER_A=eHUqU2Qh#$hTOHpoDQ==

Environment

Ben8t commented 1 month ago

@pomazanbohdan can you provide the error you have when using {{ secret() }}please ?

Ben8t commented 1 month ago

@smunteankestra can you try to reproduce please 🙏 ?

smunteankestra commented 1 month ago

I've setup this flow: and added the secret via UI in the Namespace - and it works - checked on kestra latest (0.19.3) @pomazanbohdan can you provide what error it returned and how you've setup the secret?

`id: com.fprofitable-erp.local-ssh-connection namespace: evo.lab description: "Connect to a local machine via SSH and execute commands."

tasks:

disabled: false `

pomazanbohdan commented 1 month ago

I added the secret to the KV store, but the thread also failed. with a connection creds error.

And I would like to use .env_encoded secrets, so I can hide them from users.

smunteankestra commented 1 month ago

@pomazanbohdan You mean you added the "secret" value to the KV store? - tested KV and it also works fine (not a good approach to store a password in a KV store - better use the secrets)

about .env_ecoded: I also get an error io.pebbletemplates.pebble.error.PebbleException: Cannot find secret for key 'SECRET_PWD'. ({{ secret('SECRET_PWD') }}:1)

but when I check via terminal the .env_ecoded

docker exec -it a1858395d567a8694237ffa28cbeb0c5912f49e5bc42f4fdc882550107428003 cat /data/.env_encoded It returns: SECRET_PWD=UGFzc3dvcmQ= SECRET_GITHUB_ACCESS_TOKEN=bXlwYXQ= SECRET_AWS_ACCESS_KEY_ID=bXlhd3NhY2Nlc3NrZXk= SECRET_AWS_SECRET_ACCESS_KEY=bXlhd3NzZWNyZXRhY2Nlc3NrZXk=

What's next: Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug a1858395d567a8694237ffa28cbeb0c5912f49e5bc42f4fdc882550107428003 Learn more at https://docs.docker.com/go/debug-cli/

@Ben8t might be some issue here?

pomazanbohdan commented 1 month ago

I've setup this flow: and added the secret via UI in the Namespace

Can you take a screenshot of this item? I can't find anything other than KV storage.

smunteankestra commented 1 month ago

@pomazanbohdan Kestra Secrets (on UI) are present only in EE edition

image
pomazanbohdan commented 1 month ago

I use only CE 😁

Ben8t commented 1 month ago

@pomazanbohdan How did you install Kestra ? With docker-compose ? How do you pass the .env_encoded to the Kestra container ?

Within docker-compose.yml it's usually like this (see env_file key):

kestra:
    image: kestra/kestra:v0.19.3
    ...
    volumes:
      - kestra-data:/app/storage
      - /var/run/docker.sock:/var/run/docker.sock
      - /tmp/kestra-wd:/tmp/kestra-wd
    env_file:
      - .env
    environment:
      KESTRA_CONFIGURATION: |
        ...
pomazanbohdan commented 1 month ago

.env_encoded

👆 In docker-compose .env file i use as "master" password storage and don't use in docker-compose file

Ben8t commented 1 month ago

.env file i use as "master" password storage and don't use in docker-compose file

Can you details a bit more please ? How do you pass the `.env_encoded to the Kestra container then ?

Also an you share the error displayed in Kestra please ?

pomazanbohdan commented 1 month ago

docker-compose.yml

    env_file:
      - .env_encoded

.env_encoded

SECRET_USER=YWRtaW5pc3RyYXRvcg0=

error log

Auth fail for methods 'publickey,password'
Ben8t commented 1 month ago

I'm not able to reproduce on my side with fresh new instance accessible with SSH with user/password set:

id: test_ssh
namespace: company.team
tasks:
  - id: ssh
    type: io.kestra.plugin.fs.ssh.Command
    host: ec2-16-171-255-19.eu-north-1.compute.amazonaws.com
    username: ec2-user
    password: "{{ secret('SSH_PASSWORD') }}"
    commands:
      - ls -altr

This runs fine (secrets set in .env with docker-compose installation Kestra open source 0.19.3). Can you provide more details over your instance, connection details, etc. please ? Are you able to connect to your instance with user and password ?

anna-geller commented 2 weeks ago

closing given Ben couldn't reproduce

if you still encounter this issue, please share more details, perhaps a couple of screenshots using test secret (redact any sensitive data)