Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use alias in ssh config ? #4207

Closed
cadem opened this issue May 1, 2024 · 7 comments
Closed

Can I use alias in ssh config ? #4207

cadem opened this issue May 1, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@cadem
Copy link

cadem commented May 1, 2024

If I use --ssh=ssh parameter in xpra_cmd.exe, can I use host alias name in .ssh/config file?
And can I specify --ssh parameter when I use gui?

@cadem cadem added the enhancement New feature or request label May 1, 2024
@totaam
Copy link
Collaborator

totaam commented May 2, 2024

I thought it would be easier to try than to ask!
Yes, when xpra execs ssh, ssh will do whatever it normally does.
Run xpra with Xpra_cmd.exe -d ssh attach ssh://user@host/ to see more details.

@totaam totaam closed this as completed May 2, 2024
@cadem
Copy link
Author

cadem commented May 3, 2024

If I don't specify --ssh=ssh, I can connect successfully. But when I add --ssh=ssh, connection will failed.

"c:\Program Files\Xpra\Xpra_cmd.exe" -d ssh --ssh=ssh attach ssh://ubuntu@127.0.0.1:40221/100

2024-05-03 22:21:29,452 Xpra GTK3 client version 6.0-r0
2024-05-03 22:21:29,763  running on Microsoft Windows Microsoft Windows Server 2022 Standard
2024-05-03 22:21:29,763  cpython 3.11
2024-05-03 22:21:32,214 GStreamer version 1.24.2
2024-05-03 22:21:32,231 created named pipe 'Xpra\9412'
2024-05-03 22:21:32,560 keyboard layout 'Chinese (Simplified) - US Keyboard' : 'cn' (0x804)
2024-05-03 22:21:32,659 debug enabled for ['xpra.net.ssh.exec_client', 'network', 'ssh']
2024-05-03 22:21:32,665 executing ssh command: ssh -l ubuntu -p 40221 -T 127.0.0.1 'sh -c '"'"'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi'"'"''
2024-05-03 22:21:32,676  keyboard settings: layout=cn
2024-05-03 22:21:32,676  desktop size is 1600x1200:
2024-05-03 22:21:32,676   Default (423x317 mm - DPI: 96x96) workarea: 1600x1160
2024-05-03 22:21:32,676     通用非即插即用监视器       (423x318 mm)
2024-05-03 22:21:32,922 SSH EOF on stderr of ['ssh', '-l', 'ubuntu', '-p', '40221', '-T', '127.0.0.1', 'sh -c \'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi\'']
2024-05-03 22:21:32,922 remote SSH stderr:
2024-05-03 22:21:32,922 Error: failed to receive anything, not an xpra server?
2024-05-03 22:21:32,922  Host key verification failed.
2024-05-03 22:21:32,922   could also be the wrong protocol, username, password or port
2024-05-03 22:21:32,922   or the session was not found
2024-05-03 22:21:32,922 Connection failed

@totaam
Copy link
Collaborator

totaam commented May 3, 2024

Is your ssh server on port 40221? Or is it an xpra server that is forwarded to this port?
The xpra client runs:

ssh -l ubuntu -p 40221 -T 127.0.0.1 'sh -c '"'"'if command -v "xpra" > /dev/null 2>&1; then... '"'"''

The quotes look wrong to me. Perhaps it comes from here:

if nssh >= 2 and MAGIC_QUOTES:
for _ in range(nssh):
remote_cmd = shlex.quote(remote_cmd)

In which case running with xpra_cmd.exe --env=XPRA_SSH_MAGIC_QUOTES=0 ... might help.

@cadem
Copy link
Author

cadem commented May 5, 2024

I forward remote ssh(22) to local(40221).

I run the following command and paste result.

  1. "c:\Program Files\Xpra\Xpra_cmd.exe" -d ssh attach ssh://ubuntu@127.0.0.1:40221/100
    show remote app sucessfully.

2."c:\Program Files\Xpra\Xpra_cmd.exe" -d ssh --ssh=ssh attach ssh://ubuntu@127.0.0.1:40221/100

2024-05-05 15:29:11,897 Xpra GTK3 client version 6.0-r0
2024-05-05 15:29:12,230  running on Microsoft Windows Microsoft Windows Server 2022 Standard
2024-05-05 15:29:12,230  cpython 3.11
2024-05-05 15:29:14,638 GStreamer version 1.24.2
2024-05-05 15:29:14,647 created named pipe 'Xpra\8856'
2024-05-05 15:29:14,960 keyboard layout 'Chinese (Simplified) - US Keyboard' : 'cn' (0x804)
2024-05-05 15:29:15,053 debug enabled for ['xpra.net.ssh.exec_client', 'network', 'ssh']
2024-05-05 15:29:15,069 executing ssh command: ssh -l ubuntu -p 40221 -T 127.0.0.1 'sh -c '"'"'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi'"'"''
2024-05-05 15:29:15,085  keyboard settings: layout=cn
2024-05-05 15:29:15,093  desktop size is 1600x1200:
2024-05-05 15:29:15,093   Default (423x317 mm - DPI: 96x96) workarea: 1600x1160
2024-05-05 15:29:15,093     通用非即插即用监视器       (423x318 mm)
2024-05-05 15:29:15,337 SSH EOF on stderr of ['ssh', '-l', 'ubuntu', '-p', '40221', '-T', '127.0.0.1', 'sh -c \'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi\'']
2024-05-05 15:29:15,337 remote SSH stderr:
2024-05-05 15:29:15,337  Host key verification failed.
2024-05-05 15:29:15,337 Error: failed to receive anything, not an xpra server?
2024-05-05 15:29:15,337   could also be the wrong protocol, username, password or port
2024-05-05 15:29:15,337   or the session was not found
2024-05-05 15:29:15,337 Connection failed

3.ssh -l ubuntu -p 40221 -T 127.0.0.1 'sh -c '"'"'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi'"'"''
The system cannot find the path specified.

4. "c:\Program Files\Xpra\Xpra_cmd.exe" -d ssh --ssh=ssh --env=XPRA_SSH_MAGIC_QUOTES=0 attach ssh://ubuntu@127.0.0.1:40221/100

2024-05-05 15:32:51,715 Xpra GTK3 client version 6.0-r0
2024-05-05 15:32:52,020  running on Microsoft Windows Microsoft Windows Server 2022 Standard
2024-05-05 15:32:52,030  cpython 3.11
2024-05-05 15:32:54,365 GStreamer version 1.24.2
2024-05-05 15:32:54,371 created named pipe 'Xpra\10572'
2024-05-05 15:32:54,684 keyboard layout 'Chinese (Simplified) - US Keyboard' : 'cn' (0x804)
2024-05-05 15:32:54,784 debug enabled for ['xpra.net.ssh.exec_client', 'network', 'ssh']
2024-05-05 15:32:54,784 executing ssh command: ssh -l ubuntu -p 40221 -T 127.0.0.1 'sh -c '"'"'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi'"'"''
2024-05-05 15:32:54,801  keyboard settings: layout=cn
2024-05-05 15:32:54,817  desktop size is 1600x1200:
2024-05-05 15:32:54,817   Default (423x317 mm - DPI: 96x96) workarea: 1600x1160
2024-05-05 15:32:54,817     通用非即插即用监视器       (423x318 mm)
2024-05-05 15:32:55,052 SSH EOF on stderr of ['ssh', '-l', 'ubuntu', '-p', '40221', '-T', '127.0.0.1', 'sh -c \'if command -v "xpra" > /dev/null 2>&1; then xpra _proxy "100";elif [ -x $XDG_RUNTIME_DIR/xpra/run-xpra ]; then $XDG_RUNTIME_DIR/xpra/run-xpra _proxy "100";elif [ -x /usr/local/bin/xpra ]; then /usr/local/bin/xpra _proxy "100";elif [ -x ~/.xpra/run-xpra ]; then ~/.xpra/run-xpra _proxy "100";elif [ -x Xpra_cmd.exe ]; then Xpra_cmd.exe _proxy "100";else echo "no run-xpra command found"; exit 1; fi\'']
2024-05-05 15:32:55,052 remote SSH stderr:
2024-05-05 15:32:55,052 Error: failed to receive anything, not an xpra server?
2024-05-05 15:32:55,052  Host key verification failed.
2024-05-05 15:32:55,052   could also be the wrong protocol, username, password or port
2024-05-05 15:32:55,052   or the session was not found
2024-05-05 15:32:55,052 Connection failed

@totaam
Copy link
Collaborator

totaam commented May 5, 2024

@cadem as per #4207 (comment), have you tried running with magic quotes off?

Silly question: how is ssh installed on MS Windows?
Using ssh=ssh is not a supported configuration on MS Windows, ssh=plink is, and only for non-light builds.

@cadem
Copy link
Author

cadem commented May 6, 2024

  1. I had openssh installed on my windows,
    C:\Users\Administrator>ssh -V
    OpenSSH_for_Windows_9.4p1, LibreSSL 3.7.3

  2. I plink, it works, but plink doesn't support alias name in .ssh/config file.

@totaam
Copy link
Collaborator

totaam commented May 6, 2024

So, I gave it a go and it is definitely possible, but tricky.
There seems to be some conflict between the system parsing xpra's command, then xpra parsing the ssh option within that, then the windows shell parsing the command again when we execute ssh..

FWIW, with 6.1-r35740, I can connect via ssh using openssh:

./Xpra_cmd.exe attach ssh://192.168.0.10:10000/ \
    -d ssh --ssh="ssh -v -o UserKnownHostsFile='C:\msys64\home\Windows\ 10\ Test\.ssh\known_hosts'"

But beware that anything which requires user interaction (password or key passphrase, etc) will fail and show this in the output with ssh -v:

 debug1: read_passphrase: can't open /dev/tty: No such device or address

That's because the stdin, stdout and stderr pipes are attached to the parent xpra process so that it can use them to communicate with the remote proxy.

And I have no idea how to tell ssh to use either our own tool for the prompts (what SSH_ASKPASS is meant to do) or how to make it use another tty.. (ie: tty outputs /dev/pty0 on my system).

Some links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants