contabo / cntb

Contabo Command Line Interface
https://contabo.com
GNU General Public License v3.0
179 stars 24 forks source link

--oauth2-password= cannot contain & character #12

Closed michelvankessel closed 2 years ago

michelvankessel commented 2 years ago

--oauth2-password= doesn't accept all special characters.

example --oauth2-password=#3N5646Y4&5%$*7K%wP#BzhP

generates the following error [1] 30820 zsh: command not found: 5%7K%wP#BzhP

& is not accepted in my case on MacOS with zsh

Michel

Maximilian-Temeschinko commented 2 years ago

Hello michelvankessel,

try setting passwords and other strings with single quotes '-symbol around them in order for your shell to not interpret any special characters but to take everything in between the quotes as plain text.

for example try:

cntb config set-credentials --oauth2-password='#3N5646Y4&5%$*7K%wP#BzhP'

this should take the string with #-symbol as first and the P as last character as your password.

PS: Just to be sure. Please keep in mind that this is a public thread and every password that is written here would not be safe to use anymore.

Best regards max

michelvankessel commented 2 years ago

Thanks for the information @Maximilian-Temeschinko .

I can confirm that it works by adding the single quotes. Is this mentioned in the documentation? It wasn't very clear to me.

Thanks for the clarification!

p.s. passwords are just examples ;-)

Maximilian-Temeschinko commented 2 years ago

It has more to do with how your "shell" / "terminal" / "command line utility" works. In your case zsh tries to interpret the &-symbol. It is used to send a command to the "background". e.g.: echo "Hello World!" & does not print "Hello World!" onto the current active terminal but opens a new process.

So in order to "tell" your shell to not interpret any characters there, we use the quotes. I'm a gnu/linux fanboy so here is the docs of bash on this point https://www.gnu.org/software/bash/manual/bash.html#Single-Quotes, but most of the things there also apply to zsh.

caution, overexplanation following

From what i can tell what happens when we run:

cntb config set-credentials --oauth2-password=#3N5646Y4&5%$*7K%wP#BzhP

the command:

cntb config set-credentials --oauth2-password=#3N5646Y4

will be executed in the background, then the rest:

5%$*7K%wP#BzhP

will be interpreted as next command where $* is also interpreted (https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters) but resolves to empty string

so with the output: "[1] 30820" zsh tells us that it send the command to the background and it got the PID 30820 and then it tells us that it does not know any programm called "5%7K%wP#BzhP" to run next.

michelvankessel commented 2 years ago

thanks for explaining