rundeck-plugins / ansible-plugin

Ansible Integration for Rundeck
MIT License
330 stars 100 forks source link

Add newline for the ed25519 keys in key-storage #321

Closed VeselaHouba closed 6 months ago

VeselaHouba commented 2 years ago

https://github.com/rundeck-plugins/ansible-plugin/blob/ca99ed73691b883441d1fe64401e572665e7b20a/src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunner.java#L452

When you use ed25519 key saved in internal keystore, ansible fails to load it (due to bug described in here https://github.com/ansible/awx/issues/9082) . Keystore also trims all whitespaces from private keys.

It's easily replicable by setting custom key path in OS, e.g. /home/rundeck/.ssh/tmpkey

Failed job shows:

Load key \"/tmp/ansible-runner15642916951046228986id_rsa\": invalid format\r\n<user>@<ip>: Permission denied (publickey)."

and by simply adding newline issue goes away.

echo >> /home/rundeck/.ssh/tmpkey

job result

<machine> | CHANGED | rc=0 >>

But we would like to use keystore and not have keys lying around the machine for longer than necessary.

VeselaHouba commented 2 years ago

looks like it's not only newline at the end of file problem, but rather \r\n vs \n issue. Sending PR soon