As per this answer, I tried to edit, say, /etc/resolv.conf
as a super user on my vagrant box by using the following command:
C-x C-f /[email protected]#2200|sudo:127.0.0.1#2200:/etc/resolv.conf
But it just opened a file on my local machine, reporting /[email protected]#2200|sudo:127.0.0.1#2200:/etc/
as my PWD and telling me to use some M-x
command to create the directory, since it didn't exist.
Meaning it didn't connect to my vagrant box. But when I type
C-x C-f /[email protected]#2200:/etc/resolv.conf
It opens the file just fine in a read-only buffer (not using sudo) on my vagrant box.
How does one open a remote file on a vagrant box (note the NAT connection which vagrant uses by default above) with sudo access using Emacs 24.3? (I'm on Fedora 20.)
The
#port
syntax is only supported for SSH-based connection types, so it's confusing thesudo
hop. You could try something likebut this has the same problem outlined in the answer you linked: the HOST for the dynamic proxy entry will now be
127.0.0.1
, which is your local system, which prevents/sudo::
from working locally.You can avoid this by giving your Vagrant machine a name.
This is almost trivial if you add an entry to
~/.ssh/config
, e.g.and then use
C-x C-f /ssh:vagrant|sudo:vagrant:/etc/resolv.conf
. This has the added benefit of being much shorter to type.The configuration block came from
vagrant ssh-config
.