Vim edits a file from machine B through machine A

For example, I have two remote computers. Let them say A, B. Usually I can do vim scp: // A / path / file to remotely edit files on the local computer. So, is there a way to edit machine B, which can only be accessed from A, from the host machine using vim directly? Thank you very much.

  The topology:
   + ------------------------------------------------- -------------- +
   |  |
   |  |
   |  + -------------- + + ----------- + + ----------- + |
   |  |  |  |  |  |  |  |
   |  |  HOST |  + ----> |  A | + ---> |  B |  |
   |  |  |  |  |  |  |  |
   |  + -------------- + + ----------- + + ----------- + |
   |  |
   + ------------------------------------------------- -------------- + 
+6
source share
1 answer

I agree with @Conner that this is an ssh tunnel question, but anyway this is a possible answer.

  • Install netcat on host "A"
  • Add this to your $ HOME / .ssh / config:

    Host RemoteHost Hostname B User UsernameOnB Port 22 ProxyCommand ssh UsernameOnA@A 'nc %h %p' 

You will need to replace "A", "B", "UsernameOnA" and "UsernameOnB" with the appropriate hostnames or IP addresses for A and B (and check if netcat is set to "nc" or "netcat" I saw both ..)

After that you can:

 $ vim scp://RemoteHost/path/to/file 

This setting works best if you have access to public keys for both systems, otherwise you will be asked to enter passwords.

0
source

All Articles