Using vim to remotely edit a file on server B, accessible only from server A

Although I have never tried this, it is possible to remotely edit the file in vim, as described here . In my specific case, access to the server that I need access to can only be accessed from the campus, so I need to log in to my university account like this:

ssh user@login.university.com

and then log in to the secure server as follows:

ssh user@secure.university.com

I have keyless ssh, so I can automate the process as follows:

ssh user@login.university.com -t "ssh user@secure.university.com"

In any case, to remotely edit the file, for example secure.university.com/user/foo.txton my local machine?

EDIT:

vim , ( .vim folder, copy .vimrc), ( vim , vim, ), vim , , . , - ( scp, )

vim scp://user@login.university.com scp://user@secure.university.com//home/user/foo.txt
+5
3

, . ( ) .ssh/config , . ​​, .

Host secure
  User          Julius
  HostName      secure.university.com
  ProxyCommand  ssh Tiberius@login.university.com nc %h %p 2> /dev/null

( scp) secure.university.com:/home/Julius/fee/fie/fo/fum.txt

scp secure:/home/Julius/fee/fie/fo/fum.txt fum.txt

, vim :

vim scp://secure//home/Julius/fee/fie/fo/fum.txt

badd :

:badd scp://secure//home/Julius/fee/fie/fo/fum.txt

, .vimrc :

nnoremap <leader>scp :badd scp://secure//home/Julius/fee/fie/fo/fum.txt

vim , , , C :

#include "foo.h"

"foo.h"

+4

, SSHed , ( vim) . vim, .

0

Since you use ssh, you basically have access to the server through the CLI, as if you were sitting in front of the machine itself. With that said, you can use any program on this machine, as well as use it on your machine. Assuming that it secure.university.com/user/foo.txtmeans that there is a text file with a name foo.txtin a location /useron a secure server, then the following commands will work after logging in via ssh:

cd /user
vim foo.txt

You can also use nano or any other CLI-based editor that is installed on the computer.

0
source

All Articles