Question to gvm_cli

Hello together.

I make my first steps with using of gvm_cli.

my first call
gvm_cli tls --host=localhost --xml="<get_version/>" is successful.
BUT when I try
gvm_cli tls --host=localhost --xml="<get_tasks/>"
I get following error:
First command must be AUTHENTICATE, GET_VERSION, COMMANDS.

Thats why I’ve made following
./gvm-cli tls --hostname=localhost --xml=" <authenticate> <credentials><username>test</username><password>test</password> </credentials></authenticate>"
Response 200 OK.
then I’ve tried to call get_tasks one more time.
The same error, that the first command must be authenticate.
I’m confused.
How should I structure my calls.

THANK YOU

Most GMP commands need an authentication. The authentication is only valid for the current connection. If the connection is closed the authentication session is closed too.

gvm-tools have command line arguments for handling the gmp authentication out of the box. Please take a look at --gmp-username and --gmp-password arguments.

2 Likes

Hey bricks, thank you for your reply.

I tried to use --gmp-password as following:
./gvm-cli tls --gmp-username test --gmp-password test --hostname=localhost --xml="<get_tasks/>"

following error occurs:
usage: gvm-cli [-h] [-c [CONFIG]]
[–log [{DEBUG,INFO,WARNING,ERROR,CRITICAL}]]
[–timeout TIMEOUT] [–gmp-username GMP_USERNAME]
[–gmp-password GMP_PASSWORD] [-V] [–protocol {GMP,OSP}]
CONNECTION_TYPE …
gvm-cli: error: unrecognized arguments --gmp-username --gmp-password test

very strange. I’ve written the words correct. any ideas?

./gvm-cli --gmp-username test --gmp-password test tls --hostname=localhost --xml="<get_tasks/>"

2 Likes

thanks, it works. I tried to move configuration to config file /home/gvmclient/.config/gvm-tools.config:

[unixsocket]
socketpath=/var/run/openvassd.sock

[gmp]
gvm_username=test
gvm_password=test

and try to call
gvm-cli --config="/home/gvmclient/.config/gvm-tools.config" tls --hostname=localhost --xml="<get_tasks/>"
what is wrong in this call or configuration??

Please take a look at https://gvm-tools.readthedocs.io/en/latest/config.html#gmp-section for comparing what’s wrong with your settings.

1 Like