xpipe-io / xpipe

Your entire server infrastructure at your fingertips
https://xpipe.io
Apache License 2.0
3.42k stars 88 forks source link

ProxyJump No such host is known #207

Closed L1miter closed 6 months ago

L1miter commented 8 months ago

I'm encountering an issue with ProxyJump using a customized SSH connection in Xpipe. Despite successfully adding the host through both customized and simple SSH connections, and even importing an SSH config file, I still receive a "No such host is known" error with ProxyJump. I was able to sort of make it work by doing this: ProxyJump username@ipaddress:port but this method ignores IdentityFile for the ProxyJump host so I need password authetication for the proxyjump host which is not ideal since IdentityFile is more secure is there any way to resolve this?

crschnick commented 8 months ago

Does this happen outside of XPipe as well? I.e. if you put the same contents into your local SSH config file and open that connection in your terminal without xpipe involved.

L1miter commented 8 months ago

No going through powershell terminal and using ssh host connects to the desired host through ProxyJump

crschnick commented 8 months ago

Hmm, it should behave the same as XPipe delegates everything to your system shell and OpenSSH client. In this case it would be cmd.exe and the ssh command. So maybe you can try whether it also works in cmd.

Is there anything special about your setup that can cause this? This looks like a DNS error, so do you use any special DNS setup? Does that issue persist after a restart?

L1miter commented 8 months ago

Works in cmd.exe too and I don't have any special DNS setup I do have tailscale but that is disconnected I'm trying this on local net but I did try it from outside too doesn't work either

crschnick commented 8 months ago

Now the only thing that I can somehow imagine is that the SSH config handling is not exactly the same as the default ssh client handling as some global options don't get applied, but unless you have specified some options in your global or user SSH config for DNS things this shouldn't be an issue.

To narrow it down, does the manual ssh command also work in a terminal that was opened by xpipe? I.e. if you open the local machine terminal in xpipe and run your commands in there. That would rule out any environment issues.

L1miter commented 8 months ago

You mean connecting directly to a host and running commands? because that works I can connect to any host even gateway works but that pulls identity file from the host that I connect to before jump to destination host. here is an example how my ssh config looks like in my user folder

Host userver
    Hostname 192.168.0.91
    User user117
    Port 222
    LocalForward 8385 localhost:8384
    IdentityFile C:\Users\userr\.ssh\local_net

Host kubectl
    Hostname 192.168.0.56
    Port 222
    User user117
    IdentityFile C:\Users\userr\.ssh\local_net
    ProxyJump userver
crschnick commented 8 months ago

Ohh I think I misinterpreted your issue. So this is about not having access to the userver entry when referring to that in xpipe in the custom SSH connection.

I have to look up how this is handled because we are probably overriding the default ssh config setting with custom SSH connections, so it does not have access to the original config. I have to think about how to fix this.

The No such host is known error sounded to me like a DNS issue. SSH error messages are not great ...

L1miter commented 8 months ago

Yes I meant that I added that userver using the customized SSH connection in xpipe and then I added the kubectl host the same way just added the ProxyJump userver at the end and that is how it gives the No such host is known error. this is the form I used in the customized SSH connection for userver and kubectl: userver:

User user117
Hostname 192.168.0.91
Port 222

after I set the identity file and then I gave the connection name as userver kubectl:

User user117
Hostname 192.168.0.56
Port 222
ProxyJump userver

here its the same except connection name is kubectl

crschnick commented 8 months ago

Yeah that is not supported currently. I have to think about how to handle it the best way.

Now in theory you can use a hacky solution and add both systems in the same custom connection entry like this: image by just pasting everything into the text field without the first host line, which will get added automatically by xpipe:

    Hostname 192.168.0.56
    Port 222
    User user117
    IdentityFile C:\Users\userr\.ssh\local_net
    ProxyJump userver

Host userver
    Hostname 192.168.0.91
    User user117
    Port 222
    LocalForward 8385 localhost:8384
    IdentityFile C:\Users\userr\.ssh\local_net
L1miter commented 8 months ago

Maybe a way for xpipe to compare it to connection name in added hosts into xpipe and it would use the config for that to proxyjump to host? Also I noticed that when I load a config file with the SSH Config FIle and I have a host added in that file it won't connect. I input the Config location give a Connection name but it does not connect to the host. ssh_config1 ssh_config2 and this is the content of the config file:

Host userver
    Hostname 192.168.0.91
    User user117
    Port 222
    LocalForward 8385 localhost:8384
    IdentityFile C:\Users\userr\.ssh\local_net

could it be a problem that I use tab spaces and not normal space on all lines like Hostname or User and so on?

crschnick commented 8 months ago

Yeah maybe I can somehow compare the names of other custom SSH connection entries.

About the added config file, what happens when you click on the refresh button on the right side?

L1miter commented 8 months ago

Nothing happens doesn't do anything I mean it does try to load something I think it does a load animation on the host but nothing really happens. could it be a problem that I use tab spaces and not normal space on all lines like Hostname or User and so on?

crschnick commented 8 months ago

So I created the file with the same contents like this: image image and it loads for me: image

crschnick commented 8 months ago

The formatting is irrelevant, you don't need any whitespace at all in theory as that one is automatically removed when parsing it.

L1miter commented 8 months ago

I got it to work now I moved it with Move to to default group and now it works. didn't try that until now thanks for the help I saw it on your image that you had it little differently grouped so I tried that now it works.

crschnick commented 8 months ago

Oh you had it added in the all connections category? That should work without problems, let me try to see what's wrong. Another bug to add to my list.

L1miter commented 8 months ago

I don't know if it is maybe because of windows I'm running xpipe on windows. It grouped it under Local Machine automatically not under default group after I moved it to default group it works.

L1miter commented 8 months ago

Yeah that is not supported currently. I have to think about how to handle it the best way.

Now in theory you can use a hacky solution and add both systems in the same custom connection entry like this: image by just pasting everything into the text field without the first host line, which will get added automatically by xpipe:

  Hostname 192.168.0.56
  Port 222
  User user117
  IdentityFile C:\Users\userr\.ssh\local_net
  ProxyJump userver

Host userver
  Hostname 192.168.0.91
  User user117
  Port 222
  LocalForward 8385 localhost:8384
  IdentityFile C:\Users\userr\.ssh\local_net

Using this method for me gives me message that configuration must contain only one host configuration. io.xpipe.core.util.ValidationException: Configuration content must contain exactly one host configuration

crschnick commented 8 months ago

Yeah that was an error on my part. I totally forgot that it actually validates this config like that. So for now you are best off creating a SSH config file for situations when multiple hosts are needed and refer to each other (and making sure that you are in the right category, because otherwise the display won't refresh properly).

I hope that I can improve this situation soon. The display bug will definitely be fixed in the next release.

L1miter commented 8 months ago

Yeah, I just tried it that way. I created a config file with two hosts and then added them to Xpipe through SSH Config File. This approach worked for ProxyJump, although I had to move the connection name to default. This separated the two hosts from the original connection name. Then, I had to move both hosts separately to default again. After that, they grouped back together under the original connection name, but this approach worked.

crschnick commented 8 months ago

Yeah I have to admit the connection hierarchy organization in general can become a little bit confusing to handle. Maybe I will also get around to improving that some day

L1miter commented 8 months ago

Xpipe offers better organization than something like putty, another valuable feature would be automatic detection of LocalForward, RemoteForward, and DynamicForward settings in the config file when hosts are added through the SSH Config File. I understand that I can manually add tunnels and it works, but this detection would be helpful solely to display the configured forwards for the host, not to enable or disable them. This would provide a clear overview of available ports.

crschnick commented 8 months ago

Yeah that is already on my todo list, sadly the current data model is not that flexible to differentiate between different types of connection types like that. That is also related to the fact that the SSH tunnel support was implemented before the ssh config support.

crschnick commented 8 months ago

This is now partially addressed in 8.4. The refresh bug is fixed, plus the description for the custom SSH connection has been updated to go into more detail for cases like yours.

I will keep this issue open until this has been properly fixed

judzk commented 7 months ago

Just to follow, it's the same thing with The bastion. In ssh i can use : ssh -p 222 -A judzk@bastions.**** root@10.231.7.6 But i don't know how to replicate it in xpipe :) Here some howto https://blog.octo.com/le-bastion-ssh

crschnick commented 7 months ago

So in your case, this won't work because xpipe will set the RemoteCommand to none, mainly because this would cause problems otherwise. The problem here is that the bastion does have its own scheme and usage of the parameters as it uses their own custom login shell. So this is probably hard to fix. For now, opening a connection to the bastion itself is the best we can do. So you would have to type the actual connection information manually once connected.

judzk commented 7 months ago

Hmm too bad, it's working great on mobaXterm side juste with this image

crschnick commented 7 months ago

Yeah technically xpipe could allow it, but many people use this command to be executed for things like tmux or other stuff that will mess up the terminal connection and confuse xpipe. That is why it was disabled in the first place, because some users asked why their commands caused xpipe to break.

I can try to maybe find a solution to this

crschnick commented 6 months ago

@L1miter Alright, the issue about the ProxyJump names is now fixed in 9.0. You can define multiple hosts in a custom connection now. I was not able to make it work so you can refer other connections from there, but this solution should work well enough.

@judzk The remote command has also been reworked and this should work properly now in 9.0. You can now specify RemoteCommand values for connections and they will be executed.