bash_kernel icon indicating copy to clipboard operation
bash_kernel copied to clipboard

Can't use sudo

Open thwee-alchemist opened this issue 6 years ago • 4 comments
trafficstars

I really love the concept of this. I see how productivity would improve by being able to document shell scripts, and tinker with them at the same time. However, I noticed that sudo won't work because it requires special input, I guess.

thwee-alchemist avatar Feb 24 '19 10:02 thwee-alchemist

Yup, in general commands that require input don't work. There's a mismatch between the way Jupyter 'thinks about' input (something has to ask for a line of input), and the way terminals do it (you can send input at any time, and it's up to a program when it reads it).

Someone just suggested a possible idea to bridge those two models; it's not clear yet how practical it is: https://github.com/pexpect/pexpect/issues/557

takluyver avatar Feb 25 '19 11:02 takluyver

Do you know if it's possible to set the bash to run as a certain user, and just give that user non-password access? I'm doing some system maintenance, and was hoping to document my adventures in a notebook.

thwee-alchemist avatar Feb 25 '19 14:02 thwee-alchemist

You could run the entire notebook server as a particular user (we don't recommend running it as root, but it's possible if you want to take that risk). Other than that, you'd have to hack bash_kernel to start bash as a different user. Here's where it launches bash:

https://github.com/takluyver/bash_kernel/blob/0966dc102d7549f5c909c93de633a95b2af9f707/bash_kernel/kernel.py#L94-L96

takluyver avatar Feb 25 '19 16:02 takluyver

This would be really useful for installations, just download the notebook and run the commands, documentation included. If only sudo worked. As it stands, one would have to go through the extra step of downloading the file as a script, and running it as superuser, if trusted. Not the end of the world for one person, but it adds up spread out across humanity ever.

thwee-alchemist avatar Mar 01 '19 04:03 thwee-alchemist