Can I execute a shell command that requires input in ipython and/or an ipython notebook?
When I execute such a command, I see it\'s prompt, but no apparent way to p
Many programs that require a password provide a variety of ways to prompt the user for it so that jupyter
doesn't have to do it for you. The sudo
command has a -A
option and the SUDO_ASKPASS
environmental variable. I've used it like this to use sudo to get permissions for the /var/log/btmp.1
file:
In [1]: !SUDO_ASKPASS=/usr/bin/ssh-askpass sudo -A lastb -a -f /var/log/btmp.1 | head
Similarly, for your case, ssh
has an SSH_ASKPASS
environmental variable.
Note that for headless operation of ssh/rsync, you can avoid authentication prompts from a notebook entirely by directly setting up an ssh agent (if it isn't running already) and referring to it with your SSH_AUTH_SOCK
variable, like ssh-add
does.
Or you can use a different program via SSH_ASKPASS
which handles authentication in a custom way. See questions like How to automate SSH login with password? - Server Fault for more details, but be careful to not compromise your security especially when trying to automate connections from one server to another.