Create targets from CLI


I am trying to experiment a bit with the tools provided in your GitHub I wanted to try out the but I get an error that says gvm.errors.GvmResponseError: Response Error 400. One of PORT_LIST and PORT_RANGE are required, even though the documentation says, that there is just an IP of the GVM host name and a text-file containing hostnames needed. Can someone please tell me where I’m wrong or if I’m wrong?

Thanks ins advance

I figured out, that the source code didn’t provide a port_list_id in the create_target function, so I just added it and it worked :slight_smile:

1 Like

Hi, We are facing this same problem. Could you show me what you added in the to specify the port_list_id ?

Thanks this was helpful. FYI for anyone else using this. You have to get the port_list_id UID from the web console (we got ours from doing an export) and then put in the code block where Don specified.

Kinda stinks that you have to modify the script from git, but hey - it works!

1 Like

@rootbeard42 please share the working script, so it can be fixed reused by others…


I will update the mentioned script!

1 Like

I have fixed the script.

After merging can add a port_range (will result in creating a new port_list with that range) or a port_list_id (by giving a UUID) to the script.

The default behavior of the script has not been changed

 gvm-script --gmp-username xyz --gmp-password abc ssh --hostname <host> scripts/ <host> <file>

will default to create targets with the standard port_list_id of All IANA assigned TCP and UDP ("4a4717fe-57d2-11e1-9a26-406186ea4fc5")

You can use +pl/++port_list_id to add your own ID or +pr/++port_range to create a new port list (T: 1-1234 or U: 3-4, …) See documentation.

If you have any further problem, please let me know.