2

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.

2

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 | |
1

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

/ssh:you@remotehost|sudo:oracle@remotehost:/path/to/file
| 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
  • This appears to work (prompts for password) but after entering the password, autocomplete for the remote path stops working, and it keeps prompting for the password as I type a filepath. If I manually type the whole filepath, it asks if I want to create a directory (which should already exist) so I suspect it's the wrong location somehow. Using Emacs 26.3, spacemacs 0.200.13, tramp 2.3.5.26.3. password-cache is set to t. Any suggestions? – Alex Shroyer Aug 13 at 14:35
  • It will prompt for your password to ssh to remotehost. Then it will prompt for your password again to do the sudo su oracle. Depending on what fancy spacemacs autocomplete stuff is going on, you might see some weirdness. I use ido and sometimes when doing complicated tramp stuff like this I have to hit c-f to exit ido and get plain-vanilla emacs behavior. – Bryan Murdock Aug 14 at 15:43
0

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

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.