#2867 closed defect (fixed)
cli ssh assumes host is command
Reported by: | devin | Owned by: | devin |
---|---|---|---|
Priority: | major | Milestone: | 4.1 |
Component: | android | Version: | 4.0.x |
Keywords: | Cc: |
Description
I'm using xpra to start a graphical application on a host machine that is reached after 2 previous ssh connections. Unfortunately for some reason the way I write the connection command it has some problems. it currently treats the host of the xpra server as a command to run.
xpra start --ssh="ssh user@bastion ssh shell.bastion" ssh://user@activejob --remote-xpra="/home/u4/user/base_xpra" -d ssh 2020-08-28 10:46:03,287 parse_ssh_string(ssh user@bastion ssh shell.bastion) Warning: vendor 'Intel Open Source Technology Center' is greylisted, you may want to turn off OpenGL if you encounter bugs 2020-08-28 10:46:04,207 Xpra GTK3 X11 client version 4.0.2-r26625 64-bit 2020-08-28 10:46:04,319 running on Linux Ubuntu 20.04 focal 2020-08-28 10:46:04,322 window manager is 'GNOME Shell' 2020-08-28 10:46:04,349 Warning: failed to import opencv: 2020-08-28 10:46:04,349 No module named 'cv2' 2020-08-28 10:46:04,350 webcam forwarding is disabled 2020-08-28 10:46:04,669 GStreamer version 1.16.2 for Python 3.8.2 64-bit 2020-08-28 10:46:04,670 Warning: no pulseaudio information available 2020-08-28 10:46:04,670 No module named 'distutils.spawn' 2020-08-28 10:46:04,830 No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate' 2020-08-28 10:46:05,111 Warning: vendor 'Intel Open Source Technology Center' is greylisted, 2020-08-28 10:46:05,111 you may want to turn off OpenGL if you encounter bugs 2020-08-28 10:46:05,216 OpenGL enabled with Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2) 2020-08-28 10:46:05,229 executing ssh command: "ssh" "user@bastion" "ssh" "shell.bastion" "-l" "user" "-T" "activejob" "sh -c 'xpra initenv;if [ -x /home/u4/user/base_xpra ]; then /home/u4/user/base_xpra _proxy_start "--ssh=ssh user@bastion ssh shell.bastion" "--debug=ssh" "--remote-xpra=/home/u4/user/base_xpra";else echo "no run-xpra command found"; exit 1; fi'" 2020-08-28 10:46:05,355 keyboard settings: rules=evdev, model=pc105, layout=us 2020-08-28 10:46:05,358 desktop size is 1366x768 with 1 screen: 2020-08-28 10:46:05,358 :0.0 (361x203 mm - DPI: 96x96) workarea: 1294x741 at 72x27 2020-08-28 10:46:05,358 BOE LVDS-1 (309x173 mm - DPI: 112x112) bash: activejob: command not found bash: line 2: syntax error near unexpected token `(' bash: line 2: `Tp��~�g�fc՟�&�V�&���L%\��Z�d3�{�ZX'�k���i�^�yb���Y�r���c�j�NZ@RfT�ibS����-Np�nJ�F�wbS���lI�W��+��!��0�)dr�ᤣ�j�5'�8�M[���&�B���n�M7*�k �N�[S����R�U�wZi��g�0_�����ĺ|�2�k��u��g9r�#��x�h���/�`/i�/O;�ЫN9Q��nDnڷ(2�<�Q�j:s7�o�]�'k��匎�Dz�#;�s��mW�ł��Wve+�Ŝ���80�i�~�`FG�����U+�VGw�����ذ3� % ���� ��Ŋ5Ә��ʆ�X�6\����Y;s���(���u˭7� ��Fa��s�<тr��8��歠�qo; �{�~`-��D�$��ɏ�oH���_�X�{�kY�nQRH�"3�r)��{� �j5�M�vknՊЙ0uF%���ɛVĶ"g5��g�ّt�(P����}���ʆZ)�_�W��bwl�<R�4t�����ju��v+j�egӹl����@�hu���\��+dץ�n ,�K>1���=n���p��C' /home/u4/user/base_xpra: line 2: singularity: command not found 2020-08-28 10:46:07,606 Error: failed to receive anything, not an xpra server? 2020-08-28 10:46:07,606 could also be the wrong protocol, username, password or port 2020-08-28 10:46:07,607 or the session was not found 2020-08-28 10:46:07,607 Connection lost
Change History (8)
comment:1 Changed 6 months ago by
Version: | 3.0.x → 4.0.x |
---|
comment:2 Changed 5 months ago by
Status: | new → assigned |
---|
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.
comment:3 Changed 5 months ago by
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!
comment:4 Changed 5 months ago by
Owner: | changed from Antoine Martin to devin |
---|---|
Status: | assigned → new |
This is because the command is being parsed multiple times.
- this works:
$ 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)
comment:5 Changed 5 months ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
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!
comment:6 Changed 5 months ago by
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.
comment:8 Changed 5 weeks ago by
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2867
oops, selected the wrong version. I'm running xpra 4.0.x