I'm doing my development work on my Windows machine, but my compiling on a remote Linux machine. What I currently do is start an X server on Windows, ssh into the Linux machine, then do the development remotely.
What I'd like to do is edit my source on the Windows machine, and have it automatically copy files over to the Linux system when I save. I'd also like for my built-in compilation commands to perform a build on the remote system.
If it makes a difference, the source is all in C, using GCC. In descending order of preference, I have Emacs, Vi, and Netbeans on my desktop, and am willing to install another IDE for a last resort.
If you love to be presented with a problem that you can figure out and fix, then a coding career could actually be your dream career. Better yet, many coding careers can be done remotely — in fact, remote tech jobs have been common, both for full-time roles and freelance jobs, even before the pandemic.
The majority of software developers work from home, with 86 percent currently working entirely remotely.
As a remote software engineer, you work from home to create and develop systems using programming languages and frameworks. As part of your duties, you design and install software solutions by determining specifications and developing code.
This is certainly doable in vim. You can use the scp:// protocol within vim to edit remote files, and set up a command that writes a local copy. You can also change what program vim uses for :make to do an ssh make instead on your server.
You'll need to set up your ssh-keys to keep this painless (otherwise you'll be entering your password all the time) but that's fairly easy.
Another alternative would be to push to a remote repos as part of your make command, instead of editing remotely.
EDIT:
First, using the scp://
protocol within vim. From :help netrw-start
(or down the page from :help scp
)
Netrw supports "transparent" editing of files on other machines using urls (see |netrw-transparent|). As an example of this, let's assume you have an account on some other machine; if you can use scp, try:
vim scp://hostname/path/to/file
Want to make ssh/scp easier to use? Check out |netrw-ssh-hack|!
You can also use scp://
paths in :edit
commands, or really anywhere that you could use a normal path.
And, from the mentioned :help netrw-ssh-hack
, instructions on how to set up your ssh keys:
IMPROVING BROWSING *netrw-listhack* *netrw-ssh-hack* {{{2
Especially with the remote directory browser, constantly entering the password is tedious.
For Linux/Unix systems, the book "Linux Server Hacks - 100 industrial strength tips & tools" by Rob Flickenger (O'Reilly, ISBN 0-596-00461-3) gives a tip for setting up no-password ssh and scp and discusses associated security issues. It used to be available at http://hacks.oreilly.com/pub/h/66 , but apparently that address is now being redirected to some "hackzine". I'll attempt a summary based on that article and on a communication from Ben Schmidt:
(1) Generate a public/private key pair on the local machine (ssh client):
ssh-keygen -t rsa
(saving the file in ~/.ssh/id_rsa as prompted)
(2) Just hit the when asked for passphrase (twice) for no passphrase. If you do use a passphrase, you will also need to use ssh-agent so you only have to type the passphrase once per session. If you don't use a passphrase, simply logging onto your local computer or getting access to the keyfile in any way will suffice to access any ssh servers which have that key authorized for login.
(3) This creates two files:
~/.ssh/id\_rsa ~/.ssh/id\_rsa.pub
(4) On the target machine (ssh server):
cd mkdir -p .ssh chmod 0700 .ssh
(5) On your local machine (ssh client): (one line)
ssh {serverhostname} cat '>>' '~/.ssh/authorized\_keys2' < ~/.ssh/id_rsa.pub
or, for OpenSSH, (one line)
ssh {serverhostname} cat '>>' '~/.ssh/authorized\_keys' < ~/.ssh/id_rsa.pub
You can test it out with
ssh {serverhostname}
and you should be log onto the server machine without further need to type anything.
If you decided to use a passphrase, do:
ssh-agent $SHELL ssh-add ssh {serverhostname}
You will be prompted for your key passphrase when you use ssh-add, but not subsequently when you use ssh. For use with vim, you can use
ssh-agent vim
and, when next within vim, use
:!ssh-add
Alternatively, you can apply ssh-agent to the terminal you're planning on running vim in:
ssh-agent xterm &
and do ssh-add whenever you need.
For Windows, folks on the vim mailing list have mentioned that Pageant helps with avoiding the constant need to enter the password.
Kingston Fung wrote about another way to avoid constantly needing to enter passwords:
In order to avoid the need to type in the password for scp each time, you provide a hack in the docs to set up a non password ssh account. I found a better way to do that: I can use a regular ssh account which uses a password to access the material without the need to key-in the password each time. It's good for security and convenience. I tried ssh public key authorization + ssh-agent, implementing this, and it works! Here are two links with instructions:
- http://www.ibm.com/developerworks/library/l-keyc2/
- http://sial.org/howto/openssh/publickey-auth/
For making on remote systems, you need to set your makeprg
variable to
do an ssh make. From :help makeprg
Program to use for the ":make" command. See |:make_makeprg|. This option may contain '%' and '#' characters, which are expanded to the current and alternate file name. |:_%| |:_#| Environment variables are expanded |:set_env|. See |option-backslash| about including spaces and backslashes.
Note that a '|' must be escaped twice: once for ":set" and once for the interpretation of a command. When you use a filter called "myfilter" do it like this:
:set makeprg=gmake\ \\\|\ myfilter
The placeholder "$*" can be given (even multiple times) to specify where the arguments will be included, for example:
:set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*}
This option cannot be set from a |modeline| or in the |sandbox|, for security reasons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With