Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

siddhantdev
Copy link
Contributor

@siddhantdev siddhantdev commented Aug 31, 2025

Running :connect without any address provided will provide the user with a list of options to connect to, including ssh hosts configured on the system.
Running :connect ssh://host will attempt to connect to host via connect and run Neovim remotely on the system.

I need some help writing the tests, not sure how to do that at all for this.

For the longest time I couldn't figure out how to avoid making the user input their password multiple time for password based authentication. Got the idea for caching prompts and responses from this plugin: https://github.com/amitds1997/remote-nvim.nvim/. Thanks a lot to https://github.com/amitds1997 for their amazing work.

Reference issue: #34257

@siddhantdev
Copy link
Contributor Author

siddhantdev commented Aug 31, 2025

It seems like the tests are failing because there is no ~/.ssh/config file. Should I update the code to not throw an error if it fails to read the config or create a temporary file for the purposes of the test?

Just added a check for whether the file is readable using vim.fn.filereadable() 😅

@siddhantdev
Copy link
Contributor Author

Here is a video showcasing the connect ssh:// feature. siddhant@localhost is directed to a Linux VM running on VirtualBox. Sorry for the flickering, couldn't figure out how to screengrab properly.

output.mp4

@siddhantdev siddhantdev force-pushed the ssh-connect branch 4 times, most recently from 918cd14 to 4ef865d Compare August 31, 2025 21:10
@justinmk justinmk added the gsoc community: Google Summer of Code project label Sep 1, 2025
@siddhantdev
Copy link
Contributor Author

Linter is failing with:

/home/runner/work/neovim/neovim/runtime/lua/vim/net/_ssh.lua:294:17: value assigned to variable resp is unused

but resp is being used a few lines later here:

          ssh_prompts[i].value = resp
          processed_idx = #stdout
          vim.api.nvim_chan_send(job_id, resp .. '\n')

Not sure why it's failing

@siddhantdev
Copy link
Contributor Author

For a test, I have currently thought of this: calling `:connect ssh://localhost' should have one of three possible results (barring errors):

  1. It prompts the user for a password
  2. It asks the user whether they would like to verify the keyring
  3. It connects to a server running on localhost

So, we call :connect ... and then test for each of the separate possibilities (simply quit the command if it asks for any prompts).
Not sure how we would check for the error situations though (ssh not being installed)

Thoughts @justinmk ?

@siddhantdev
Copy link
Contributor Author

siddhantdev commented Sep 4, 2025

I didn't like how the command to find a free socket on the remote machine was working before, felt a bit flaky (there were some false positive possibilities), so I've changed it. The current method will enforce a minimum version of Neovim on the remote machine, I'm not sure if this is a problem.

@siddhantdev siddhantdev requested a review from justinmk September 4, 2025 23:16
@siddhantdev siddhantdev force-pushed the ssh-connect branch 2 times, most recently from 2b8f6fc to 55fcf8f Compare September 5, 2025 17:33
Running `:connect` without any address provided will provide the user
with a list of options to connect to, including ssh hosts configured on
the system.
Running `:connect ssh://host` will attempt to connect to host via
connect and run Neovim remotely on the system.
@siddhantdev
Copy link
Contributor Author

I've added a few basic test which does validation on the address passed to ssh.connect_to_host() (can't be nil, cant be empty, can't contain spaces)

@justinmk
Copy link
Member

justinmk commented Sep 7, 2025

Not sure how we would check for the error situations though (ssh not being installed)

Exercising the codepaths is the first priority. Exercising failure modes is also important, but can be a later step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc community: Google Summer of Code project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants