Skip to content

SSH_AUTH_SOCK is not set when running cron jobs #128

@alexander-danilenko

Description

@alexander-danilenko

Description

I've configured crontab as per documentation, but when I'm trying to connect to any SSH inside my cron job it fails on access denied (public key) error.

Steps to reproduce:

  1. touch ./docksal/services/cli/crontab
  2. Add following to recently created file:
    * * * * * bash -lc 'env >> /tmp/cron-test.log 2>&1'
    
  3. fin reset cli

Result: once cron will run it will write current environment variables to /tmp/cron-test.log file and there is no SSH_AUTH_SOCK which indicates what ssh keys (what socket) should be used.
Expected behavior: SSH_AUTH_SOCK should be available in crontab job.

Temporary solution:

For me just adding SSH_AUTH_SOCK environment variable at the very beginning of crontab file helped. So following works good and i'm getting no ssh errors with this trick.

.docksal/services/cli/crontab content:

SSH_AUTH_SOCK=/.ssh-agent/proxy-socket
* * * * * bash -lc 'env >> /tmp/cron-test.log 2>&1'

I believe it should be either documented here or automated.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions