riscy / shx-for-emacs

An Emacs shell-mode (and comint-mode) extension that enables displaying small plots and graphics and lets users write shell commands in Emacs Lisp.
GNU General Public License v3.0
218 stars 10 forks source link

Feature request :su and :ssh-sudo #24

Open a-schaefers opened 3 years ago

a-schaefers commented 3 years ago

for example, I can type:

C-xC-f /
/ssh:serv1|sudo:root@serv1:
RET

And immediately be tramp root on the remote server. Sudo is more useful than su in this case because not everyone has the root password on a remote server, but many people do have sudo -i access to root.

Additionally if we put in ~/.authinfo or ~/.authinfo.gpg sudo password credentials for the remote server,

machine serv1 login root port sudo password MYSUDOPASSWORD

and if in ~/.ssh/config we have something like,

Host serv1 HostName serv1.example.com User MYUSERNAME

We can securely tramp as root on remote servers via sudo not needing a password or anything. It can be quite handy. I'd love to have this with a shell-mode shortcut similar to :ssh

In like manner,

:su would be nice for quickly becoming tramp root on your local machine, with e.g. something similar to,

(cd (concat "/su:" (system-name) ":"))
(shell)

and this would not require root's password again, if stored as follows in ~/.authinfo.gpg

machine HOSTNAME login root password MYPASSWORD

a-schaefers commented 3 years ago

Note: with Emacs 27 or higher it will automatically ask you the credentials and populate your .authinfo file for you, too!

riscy commented 3 years ago

Apologies for the delayed reply -- this looks like a solid idea.