开发者

How to use SSH and SUDO together with TRAMP in Emacs [duplicate]

This question already has answers here: 开发者_开发知识库 Closed 10 years ago.

Possible Duplicate:

Open file via SSH and Sudo with Emacs

I want to open a file using sudo (say, /etc/hosts) on a remote machine connected by ssh using TRAMP on Emacs.

I tried couple of options, but none of them worked. Can anybody tell me how to go about it?

Thank you


Use following in your .emacs

(set-default 'tramp-default-proxies-alist (quote ((".*" "\\`root\\'" "/ssh:%h:"))))

Then you can simply type:

C-x C-f /sudo:root@host[#port]:/path/to/file

It will ask you for your password to access remote shell and then your password again for sudo access.


In recent Emacsen and Unixes it's dead simple, just visit a file (C-x C-f) and start the file name with ssh://server:/file.

If you are using Windows, first install Putty and put it in your PATH environment variable. Then when you visit a file use plink://server:/file instead of ssh://server:/file.

EDIT:

This answer is wrong, see the answer below.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜