handling sudo interactive password requests
See original GitHub issueAny guidance on how to go about executing sudo on the remote server and dealing with interactive password prompts? Ideally I’d like to do the prompting on the client side and allow interactive authentication to work (basically shooting for how Fabric does this in python), but I’m not sure if A) I need to force tty creation during the connection (and if so, how would I do that as I don’t see any connection config option) or B) whether I can specify an “askpass” program on the remote side and somehow wire that up to the ssh2 session or C) something else entirely or D) this is sufficiently nontrivial that I should consider alternatives.
As I would mostly expect, currently running a remote sudo
results in:
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
Issue Analytics
- State:
- Created 11 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
sudo with password in one command line? - Super User
Yes, use the -S switch which reads the password from STDIN: $echo <password> | sudo -S <command>. So for your case it would...
Read more >Use sudo Command in Non-Interactive Mode - Baeldung
In this tutorial, we'll look at how to tell sudo to work in a non-interactive mode — for example, passing the password as...
Read more >How to avoid being prompted for a password by sudo?
In terminal run the visudo command to edit the sudoers file: sudo visudo. and add the following line to the sudoers list username...
Read more >Bash: automating ssh login and sudo that require interactive ...
Taking this to its logical conclusion, I would use the sshpass utility to avoid the password prompt for the initial ssh session. sshpass...
Read more >run a sudo command, specifying the password on the same line
Run the command as a user other than the default target user (usually root). The user may be either a user name or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve added the ability to allocate a pseudo-tty for exec() in f4b2aaa. Use it like so:
As a result of this change, environments are now set by:
You’ll also have to look for the sudo prompt. Example:
very good.