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

cannot establish the connection with the remote machine #94

Open
hachi-27 opened this issue Apr 25, 2023 · 23 comments
Open

cannot establish the connection with the remote machine #94

hachi-27 opened this issue Apr 25, 2023 · 23 comments
Labels
bug Something isn't working question Further information is requested

Comments

@hachi-27
Copy link

Hi,

I'm using nvim 0.8.0 and installed distant.nvim via Packer on MacOS. I have a remote machine that is running on Contabo OS. I've installed distant binary via cargo install distant and Path is also added tot he .bashrc file. I've also already defined bin path in the distant.nvim setup like this:

      require('distant').setup {
        ["Remote_IP"] = {
          distant = "/root/.cargo/bin/distant",
      },
      ['*'] = require('distant.settings').chip_default(), {
        ssh = {
          idendity_files = { '~/.ssh/id_ed25519_39k' },
          user = { 'root' },
        }
      }
    }

However, when I run :DistantLaunch <IP> then for some reason it tries to log in to a username that is defined in my local system For ex: my laptop's username is hachi then it tries to login to hachi@xxx.xxx.xxx.xxx and hachi user does not exist on my remote machine.
So I run the command as :DistantLaunch root@<IP> because I've to access the root user. but it is not working either as I'm getting the following error:

Failed (1): Failed to connect to server
Caused by:
    deadline has elapsed

Here I'm also attaching my a screenshot
Screenshot 2023-04-26 at 1 23 56 AM

Also I don't understand why is it using my ssh keys when it is making the connection using tcp rather than ssh. Any comments on that?

Please help me resolving the issue. It'd be a huge help.
Thanks

@chipsenkbeil
Copy link
Owner

If you do DistantLaunch ssh://root@xxx.xxx.xxx.xxx, this will ssh into the remote machine using the username you provide to execute distant server listen --daemon ... to spawn a server that is detached from ssh. This prints out the port and key that need to be used to connect over TCP. From there, the ssh connection will close and distant.nvim will attempt to connect over TCP to the server.

If you are getting a timeout or connection refused, this is most likely because the distant server has bound to a port that is not exposed to the Internet. You would need to specify the port that you want the server to listen on via :DistantLaunch ssh://root@xxx.xxx.xxx.xxx distant.args="--port 8080".

Alternatively, you can run distant server listen --daemon --host any --port 8080 on your remote machine directly, which will print out the key and port being used:

distant server listen --daemon --host any --port 8080
[distant server detached, pid = 50656]

distant://:59ffb73c29a06c2875ee67cb9af2dda0e07486861a7261a5bbc0da32eb8f6317@0.0.0.0:8080

From there, just replace the 0.0.0.0 with your IP address when you use DistantConnect:

:DistantConnect distant://:59ffb73c29a06c2875ee67cb9af2dda0e07486861a7261a5bbc0da32eb8f6317@xxx.xxx.xxx.xxx:8080

@hachi-27
Copy link
Author

Thanks chip for your detailed response.
However, I just tried your alternative solution and I'm still facing the exact same error that I was getting before.
Can you tell me how do I confirm if 8080 port is open to the internet?
I'm not the admin of the server though.
Thanks

@chipsenkbeil
Copy link
Owner

That was just an arbitrary port, not something guaranteed to be open on your server. You could use something like https://canyouseeme.org/ to see if a port is open on a machine with an IP.

@hachi-27
Copy link
Author

hachi-27 commented Apr 26, 2023

Hi chip,
Just checked my IP with nmap from my laptop and I can see the port is open.
Discovered open port 8080/tcp on <my remote IP>.
Which means problem is something else.
Can you suggest anything please?

@chipsenkbeil
Copy link
Owner

Have you started the server manually on that machine and then tried using DistantConnect? If so, add logging to the server via --log-level trace --log-file /path/to/file.log to see if a connections happens with the server.

@hachi-27
Copy link
Author

yes I did create the server on the remote machine.
however, if I'm trying to add a log file then I'm getting the following:

root@vmi575659:~# distant server listen --daemon --host any --port 5777 --log-level trace --log-file ~/work_himanshu/


thread 'main' panicked at 'Failed to create log file spec: OutputBadFile', /root/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-0.19.0/src/cli.rs:134:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

what can I do?

@chipsenkbeil
Copy link
Owner

You need to specify the file, not the directory. So work_himanshu/distant.log

@chipsenkbeil
Copy link
Owner

Also, I'd recommend using distant 0.20.0-alpha.4

@chipsenkbeil
Copy link
Owner

If you are using the v2 branch, that's the version suppoted right now

@hachi-27
Copy link
Author

hachi-27 commented Apr 28, 2023

I'm unable to use the pre-built binary v0.20.0 on CentOS7 because I'm getting the following errors:
which I searched online and it appears the binary was made with more recent version of linux than what I'm using rn.

./distant-linux64-gnu-x86: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.29' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.27' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by ./distant-linux64-gnu-x86)
./distant-linux64-gnu-x86: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./distant-linux64-gnu-x86)

while using crate it is giving me v0.19.0

@hachi-27
Copy link
Author

And after starting the server with the logs and tried to connect with my client. I'm getting the following logs:

[2023-04-28 14:35:35.444076 +02:00] DEBUG [/home/work/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-0.19.0/src/cli/commands/server.rs:106] Forking process
[2023-04-28 14:35:35.446546 +02:00] TRACE [/home/work/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-0.19.0/src/cli/commands/server.rs:144] Starting server using unresolved host 'Any'
[2023-04-28 14:35:35.446614 +02:00] DEBUG [/home/work/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-0.19.0/src/cli/commands/server.rs:168] Starting local API server, binding to 0.0.0.0 with port in range 5777
[2023-04-28 14:35:35.446842 +02:00] DEBUG [/home/work/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-core-0.19.0/src/api/local/state/watcher.rs:94] Watcher not configured for precise events
[2023-04-28 14:35:35.446863 +02:00] DEBUG [/home/work/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-core-0.19.0/src/api/local/state/watcher.rs:94] Watcher not configured for notice events
[2023-04-28 14:35:35.446911 +02:00] INFO [/home/work/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/distant-0.19.0/src/cli/commands/server.rs:198] Server listening at 0.0.0.0:5777

I don't think client's request is being received by the server.

@hachi-27
Copy link
Author

hachi-27 commented May 2, 2023

Hi @chipsenkbeil ,
Can you please suggest anything else?
Thanks

@chipsenkbeil
Copy link
Owner

Hey there! Apologies, I'm on vacation out of the country, so I am not regularly checking issues right now.

The v2 branch of the plugin currently requires v0.20.0-alpha.4 for compatibility. Have you tried compiling from source? Or using the musl version on linux? The issue where no message is received may be related to chipsenkbeil/distant#167, where a version incompatibility can appear like the issue you've reported. It's going to be fixed to report an error before the final v0.20.0 is released.

I've had situations where the version of Linux is so old that the GLIBC version isn't compatible, and I switched to the pre-compiled musl version such as https://github.com/chipsenkbeil/distant/releases/download/v0.20.0-alpha.4/distant-linux64-musl-x86

@chipsenkbeil chipsenkbeil added bug Something isn't working question Further information is requested labels May 15, 2023
@sangtq13
Copy link

Hi @chipsenkbeil, I am installing distant from source on ubuntu 1804. After finishing download distant with packer. I try to connect to remote server using following command "DistantLaunch my_server ssh.user=root" but terminal show the error "Failed (1): error: unrecognized subcommand 'client'
Usage: distant [OPTIONS]
For more information, try '--help'.". I try to find the solution for this problem but anything can help so I have to change to VS code to connect to remote host. Please help me the way to setup distant correctly. Thank you so much.

@chipsenkbeil
Copy link
Owner

@sangtq13 what version of distant and distant.nvim do you have? This sounds like you are using a version of distant that is too high for what the v0.2 branch supports.

You can either switch to v0.3 and use DistantLaunch root@my_server or installer the appropriate version for v0.2 as highlighted in the Readme.

@sangtq13
Copy link

@chipsenkbeil, I am using v0.2 in my current nvim. I install in packer with the following command:
use {
'chipsenkbeil/distant.nvim',
branch = 'v0.2',
config = function()
require('distant').setup {
-- Applies Chip's personal settings to every machine you connect to
--
-- 1. Ensures that distant servers terminate with no connections
-- 2. Provides navigation bindings for remote directories
-- 3. Provides keybinding to jump into a remote file's parent directory
['*'] = require('distant.settings').chip_default()
}
end
}

@chipsenkbeil
Copy link
Owner

@sangtq13 yes, you have the same issue as #104. The version of distant installed (not the plugin) is too new, I believe.

@sangtq13
Copy link

@chipsenkbeil, I switch distant to version 0.20.0-alpha.4 and this error will appear:
Failed (1): Failed to launch server
Caused by:
Fatal: ssh handshake with 192.168.30.180:22: [Session(-43)] Failed getting banner

Any idea for this problem bro. Thank you so much.

@chipsenkbeil
Copy link
Owner

@sangtq13 can you try running DistantLaunch my_server ssh.user=root options="ssh.backend=libssh"? Or, actually, I believe the v0.2 branch now would be in the format DistantLaunch ssh://root@my_server options="ssh.backend=libssh". But the main thing to try is options="ssh.backend=libssh".

@sangtq13
Copy link

sangtq13 commented Jun 27, 2023

@chipsenkbeil, I use your command and this error appears:
Failed (1): Failed to launch server
Caused by:
Invalid backend
In my case, I am trying to connect to a remote host my_server via proxy in ssh config file. Is it the case that distant support?

@chipsenkbeil
Copy link
Owner

Ah, proxy isn't supported (yet)., so I don't believe this would work. Your intention is that you have to go through one machine running ssh to connect to a second machine that is only accessible from the first?

What you can do is start distant manually on that second machine, and then create an ssh tunnel that you connect through. When I write up documentation for v0.3, I'll try to cover how to do that.

@sangtq13
Copy link

sangtq13 commented Jun 28, 2023

@chipsenkbeil, yes bro. This is the case that I want to connect to remote. I am expecting it will be supported in v0.3 because I really want to use Vim in stead of VS code and I don't want to come back using vim script. Thank you for your detailed respose. I really appreciate that.

@sangtq13
Copy link

@chipsenkbeil, How can I install v0.3 of distant?. In current, I am using following command with packer:
use {
'chipsenkbeil/distant.nvim',
branch = 'v0.3',
config = function()
require('distant').setup {
-- Applies Chip's personal settings to every machine you connect to
--
-- 1. Ensures that distant servers terminate with no connections
-- 2. Provides navigation bindings for remote directories
-- 3. Provides keybinding to jump into a remote file's parent directory
['*'] = require('distant.settings').chip_default()
}
end
}
I already checked distant installing in ~/.local/share/nvim/site/pack/packer/start/distant.nvim. However in nvim, I can not type DistantInstall. It works with v2.0. I am trying to switch to v3.0 to see it can support remote to host via proxy command. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants