TransWikia.com

tramp and sudo: how to edit files under another account

Emacs Asked by Daniel Wu on September 2, 2021

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.

3 Answers

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

Answered by Bryan Murdock on September 2, 2021

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 [email protected] mailing list.

Answered by Michael Albinus on September 2, 2021

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.

Answered by phils on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP