tunnel – SSH via jump server and then use a command

I have a jump server that I need as a bridge when running commands on another server.

I set up the jump server in my ssh config to be hopping and on the jump server, I set the final destination as lb3.

ssh -t hopping ssh lb3

The above command works. I end up at my final destination and my terminal is interactive.

However, when I want to run more complex commands I seem to have trouble with correct escaping…

For example, I’m trying to run this:

ssh -t hopping ssh lb3 "varnishadm -S /opt/varnish_secret -T ban 'req.url ~ .'"

Error message:

Command failed with error code 106 expected conditional (~, !~, == or !=) got "/home/username"

I have tried a few different ways of escaping but I can’t say that I really know what I’m doing in this case. Does anyone who is more experienced know what I need to escape to make it work?