git ssh command on aws lamda git layer error

Viewed 216

I'm running simple-git on AWS Lambda with a GIT layer (https://github.com/lambci/git-lambda-layer) and everything works fine until I use .env('GIT_SSH_COMMAND', 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ...') with a custom SSH key - it throws spawn git ENOENT.

Works perfectly fine with the SSH key on the localhost, error happens only on lambda and only with the GIT_SSH_COMMAND env.

Any ideas why is this happening?

  • Node 14 (Lambda)
  • GIT 2.29.0 (via lambda layer)
  • Lambda layer is installed properly, it works without GIT_SSH_COMMAND
1 Answers

Check where ssh is referenced in the PATH (which ssh), and use the full path of the ssh executable in your GIT_SSH_COMMAND

.env('GIT_SSH_COMMAND', 
     '/full/path/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ...')
Related