1

I am trying to run the following command in karate using karate.fork

ssh -o ProxyCommand="ssh -W %h:%p -i ~/.ssh/id_rsa root@myjumphost" -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -o PasswordAuthentication=no root@finaldest echo test

I have broken this up into an array to pass to karate.fork like so:

[
    ssh,
    -o,
    ProxyCommand="ssh -W %h:%p -i ~/.ssh/id_rsa root@myjumphost",
    -i,
    ~/.ssh/id_rsa,
    -o,
    StrictHostKeyChecking=no,
    -o,
    PasswordAuthentication=no,
    root@finaldest,
    echo test
]

Then run the command like so:

* karate.fork(args) where args is the array mentioned above

The command works when I paste it into the terminal and run it manually, however when run with karate.fork I get

zsh:1: no such file or directory: ssh -W finaldest:22 -I ~/.ssh/id_rsa root@myjumphost
kex_exchange_identification: Connection closed by remote host 

I have tried adding a few backslashes before the " in the ProxyCommand but no amount of back slashes fixes this issue. I think I am misunderstanding what karate.fork is doing to run the command, is there some internal parsing or manipulating of the given input? I was able to get this command to work when I used useShell: true however this option breaks other tests for me so I would really like to avoid it.

Owen Kuhn
  • 85
  • 6
  • without digging much, maybe `echo test` should be on two separate lines ? yes this can be tricky to figure out. refer this answer if you haven't already: https://stackoverflow.com/a/62911366/143475 - if all else fails, roll your own utility using java interop – Peter Thomas Oct 03 '22 at 23:17
  • 1
    @Peter Thomas The key was actually to just remove the double quotes in the ProxyCommand option, I guess karate is properly quoting this or doing something behind the scenes – Owen Kuhn Oct 05 '22 at 16:46

1 Answers1

1

I had to remove the double quotes, seems like they didn't play well with karate.fork and the command still runs without them

[
    ssh,
    -o,
    ProxyCommand=ssh -W %h:%p -i ~/.ssh/id_rsa root@myjumphost,
    -i,
    ~/.ssh/id_rsa,
    -o,
    StrictHostKeyChecking=no,
    -o,
    PasswordAuthentication=no,
    root@finaldest,
    echo test
]
Owen Kuhn
  • 85
  • 6