On local machine, I am using the account as test1, and I could use the same account to login remote server. After login as test1 on remote server, I could run sudo su - oracle to change as oracle user, and then I could all files under account of oracle. But I don't know the password of oracle, I could only change to oracle using sudo su - oracle. So how to use tramp to edit the file from oracle account on remote server? I read the tramp document, it said we have sudo and su option. I can't simple use su since I don't have the password of oracle. But if using sudo, looks like it doesn't work as the emacs hangs forever.


This is probably a (cross-site) duplicate, as the question has a fairly comprehensive answer on Stack Overflow:

Open file via SSH and Sudo with Emacs

But if using sudo, looks like it doesn't work as the emacs hangs forever.

As you neither show what you've tried, nor provide any details on how far tramp gets (customize the tramp-verbose option), it's extremely difficult to tell whether there's still a problem, or what it might be.

| improve this answer | |

sudo su - oracle is not supported by Tramp out-of-the-box. You would need to define an own method in tramp-methods for this, kind of tricky.

I fear it will be to detailed to fiddle it out here on stackexchange. You might rather ask on the tramp-devel@gnu.org mailing list.

| improve this answer | |
  • 2
    I think they're actually just looking for /ssh:you@remotehost|sudo:oracle@remotehost:/path/to/file – phils Oct 31 '16 at 21:15

To ssh in as you, and then run sudo su oracle, and then edit a file, do this:

| improve this answer | |
  • 1
    Please make it self standing (i.e. readable without having seen @phils's answer) – Stefan Jul 20 at 19:24
  • What @Stefan said. Comments can be deleted at any time. Thx. – Drew Jul 20 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.