No, the only way to do it is via the UI.
However, I believe you're a Linux user? Many Linux users of IBC use SSH
tunnelling to connect remotely to TWS/Gateway, with the tunnel set up so
that the connection appears to be from localhost: then the Trusted IPs list
is not needed.
I'm not sufficiently familiar with this method to spell it out without
having to look it up, and you may already be familiar with how to do it, so
I'll leave it to you to figure out.
Richard