6

For example, I have two remote machines. Let's say, A, B. Usually I can do vim scp://A/path/file to remote edit A's files locally. So, is there a way to edit machine B, which can only be accessed from A, from host machine using vim directly? Thank you very much.

The topology:
  +---------------------------------------------------------------+
  |                                                               |
  |                                                               |
  |      +--------------+        +-----------+     +-----------+  |
  |      |              |        |           |     |           |  |
  |      |    HOST      | +----> |     A     |+--->|     B     |  |
  |      |              |        |           |     |           |  |
  |      +--------------+        +-----------+     +-----------+  |
  |                                                               |
  +---------------------------------------------------------------+
Alan Dong
  • 3,981
  • 38
  • 35

1 Answers1

0

I agree with @Conner that this is a ssh-tunneling question but here is a possible answer anyway..

  • 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 would have to replace 'A', 'B', 'UsernameOnA' and 'UsernameOnB' with the matching hostnames or IP addresses for A and B (and check if netcat is installad as 'nc' or 'netcat' I've seen both..)

After that you should be able to:

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

This setup works best if you have public-key access to both systems, otherwise you will be prompted for passwords.

Shirkrin
  • 3,993
  • 1
  • 29
  • 35