I've found this question that explains how to edit a remote file with vim using:
Is it possible to do this as root (via
sudo) on the remote host?
I've tried creating a file with root permissions on the remote host and editing it with the above. Vim can see the content, can edit it, and can save it but nothing changes on the remote host (probably because vim is just saving its temp file and then giving that to scp to put back?)
When doing this with a file saved by my user it behaves as expected.
My SSH uses a key to authenticate and the remote server has NOPASSWD for my sudo access
This question is similar, but the only answer with votes uses puppet which is definitely not what I want to use.
Edit: In response to @drewbenn's comment below, here is my full process for editing:
/tmp/notouch is the file owned by root, I see vim quickly show
:!scp -q 'nagios:/tmp/notouch' '/tmp/vaHhwTl/0'
This goes away automatically to yield an empty black screen with the text
"/tmp/vaHhwTl/0" 1L, 12C Press ENTER or type command to continue
Pressing enter allows me to edit the file
Saving pops up the same kind of scp command as the beginning, which quickly and automatically goes away (it's difficult to read it in time but the scp and /tmp/... files are definitely there)