Closed totaam closed 4 years ago
Here's a more simple test case, without using remote-xpra
(which is not relevant to this ticket), and using variations on localhost
to keep things simple.
First, no hop:
xpra attach --ssh="ssh -v" ssh://antoine@localhost/ -d ssh
parse_ssh_string(ssh -v)
executing ssh command: "ssh" "-v" "-l" "antoine" "-T" "localhost" \
"sh -c 'xpra initenv;if .. exit 1; fi'"
With one hop - using 127.0.0.1
to distinguish it from localhost:
xpra attach --ssh="ssh -v -A localhost ssh -v" ssh://antoine@127.0.0.1/ -d ssh
parse_ssh_string(ssh -v -A localhost ssh -v)
executing ssh command: "ssh" "-v" "-A" "localhost" "ssh" "-v" "-l" "antoine" "-T" "127.0.0.1" "sh -c 'xpra initenv;if .. exit 1; fi'"
With two hops - using localhost.localdomain
to distinguish that part:
xpra attach --ssh="ssh -v -A localhost ssh -v -A localhost.localdomain ssh -v" ssh://antoine@127.0.0.1/ -d ssh
parse_ssh_string(ssh -v -A localhost ssh -v -A localhost.localdomain ssh -v)
executing ssh command: "ssh" "-v" "-A" "localhost" "ssh" "-v" "-A" "localhost.localdomain" "ssh" "-v" "-l" "antoine" "-T" "127.0.0.1" "sh -c 'xpra initenv;if .. exit 1; fi'"
It still fails mysteriously with 2 hops, which I will investigate.
But your command was never going to work, it should have been something like:
xpra start --ssh="ssh user1@host1 ssh user2@host2 ssh" ssh://user3@host3
To go 1-2-3.
Thanks for looking into this further, and yes that last
ssh
in the--ssh="...... ssh"
appears to be what was missing leading to the final host being treated as a command to run. I'm certainly still looking for ways to not require the numerous hops as that is the best case scenario, but that's not an xpra related issue =D. Thanks again!
This is because the command is being parsed multiple times.
$ ssh "-A" "localhost" "sh -c 'if true; then echo true;fi'"
But this does not:
$ ssh "-A" "localhost" "ssh" "-A" "localhost.localdomain" "sh -c 'if true; then echo true;fi'"
bash: -c: line 0: syntax error near unexpected token `then'
bash: -c: line 0: `sh -c if true; then echo true;fi'
You need extra escaped quotes around it:
$ ssh "-A" "localhost" "ssh" "-A" "localhost.localdomain" "\"sh -c 'if true; then echo true;fi'\""
The problem is that we can't do that in every case, as the no-hop case now fails:
$ ssh "-A" "localhost" "\"sh -c 'if true; then echo true;fi'\""
bash: sh -c 'if true; then echo true;fi': command not found
We can't reliably count how many ssh
strings we find in the ssh command to then decide how much escaping to do because ssh
could also be used as an argument, ie: ssh -v -l ssh
.
But that's still better than nothing, so that's what I've done in r27578 and all the commands from comment:2 now work properly.
This new code can be disabled with the XPRA_SSH_MAGIC_QUOTES=0
env var.
@humbletang: please test and close. (you can either apply the small patch or wait for the next beta builds)
Hi there,
Thanks for the info here. I'll make sure I add the extra escaped quotes where necessary and include the final "ssh" in the --ssh flag's contents if I'm trying to do multiple hops.
take care!
I'll make sure I add the extra escaped quotes
Adding quotes should not be needed. The new code should do the right thing.
You do need the final "ssh" in the command though.
Caused a regression with plink: #2891.
Issue migrated from trac ticket # 2867
component: android | priority: major | resolution: fixed
2020-08-28 18:48:54: humbletang created the issue