datastax / diagnostic-collection

Diagnostic Collector for Apache Cassandra
Apache License 2.0
28 stars 35 forks source link

Escape SSH password to handle special characters #138

Closed anthony-grasso-datastax closed 2 years ago

anthony-grasso-datastax commented 2 years ago

If an SSH password contains special characters such as a ; (semicolon) then sshpass will fail.

This is easily fixed by escaping the password passed to sshpass.

michaelsembwever commented 2 years ago

related: see escape_special_chars() bash function which got dummied out. We used to escape, but we stopped because it was causing problems.

anthony-grasso-datastax commented 2 years ago

Hilton and I ran into this issue today and we fixed it by placing escaped quotes around the password passed to sshpass.

The fix would be a simple one-line change

ssh_command="sshpass -p \"$sshPassword\" $ssh_command"

Note, we tested this fix on a production cluster.

mieslep commented 2 years ago

There's a better solution to this though: put the password in the environment SSHPASS and use -e, rather than passing on the command line with -p.

mieslep commented 2 years ago

https://github.com/datastax/diagnostic-collection/pull/140 should address this.

anthony-grasso-datastax commented 2 years ago

Works for me!