kas: Adding SSH key using SSH_PRIVATE_KEY fails
Environment
Docker image: kasproject/kas:2.2
SSH private key in PEM RSA format
Expected behavior
running SSH_PRIVATE_KEY=/path/to/ssh/key kas build /mnt/kas-foo.yml
in the docker container should add the SSH key to the ssh-agent using ssh-add.
Actual behavior
builder@e76a2ef8b3c4:/tmp$ SSH_PRIVATE_KEY=/path/to/ssh/key kas build /mnt/kas-foo.yml
2020-09-09 11:08:45 - INFO - kas 2.2 started
2020-09-09 11:08:45 - INFO - /mnt$ git rev-parse --show-toplevel
2020-09-09 11:08:45 - INFO - adding SSH key
2020-09-09 11:08:45 - ERROR - failed to add ssh key: b'Error loading key "(stdin)": invalid format\n'
Additional information
Manually running ssh-agent -s
and ssh-add /path/to/ssh/key
works:
builder@e76a2ef8b3c4:/tmp$ ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-Ds4LFCbiHB34/agent.122; export SSH_AUTH_SOCK;
SSH_AGENT_PID=123; export SSH_AGENT_PID;
echo Agent pid 123;
builder@e76a2ef8b3c4:/tmp$ ssh-add /path/to/ssh/key
Identity added: /path/to/ssh/key (/path/to/ssh/key)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (10 by maintainers)
Based on snipped posted by vivien I found that this works as well: