I have this running on gitlab ci, and it works for regular ssh (copied from the gitlab ci docs):
eval $(ssh-agent -s) ssh-add <(echo "$SSH_PRIVATE_KEY") mkdir -p ~/.ssh echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
This gives me
Identity added: /dev/fd/63 (/dev/fd/63)
However, when I try to rsync I get an error:
Warning: Permanently added '*****' (ECDSA) to the list of known hosts. Permission denied, please try again. Permission denied, please try again. user@server: Permission denied (publickey,password). rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]
Why is rsync not able to use the identity added, when the ssh command is?
I can also do this instead, to work around the rsync issue.
eval $(ssh-agent -s) mkdir -p ~/.ssh echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa ssh-add
Which gives me
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
Which rsync is able to use, most likely because it's in the assumed place.
Does this mean rsync uses it's own ssh implementation and not the ssh-agent on the local system?