Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add option: skip password prompting upon failure #189
Some use cases exist where a user would rather abort than be prompted in the case where their stored password is incorrect. Currently there's no option for this; the behavior to reprompt forever is hard coded.
Should be simple enough to add a new CLI flag + env var, something like
Originally submitted by Jeff Forcier (bitprophet) on 2010-07-13 at 04:44pm EDT
Closed as Done on 2011-06-21 at 06:55pm EDT
**** (matdrapeau) posted:
Patch that is able to abort or skip bad connections on remote hosts. Bad connections occurs by a wrong authentication.
The env state can take new parameters:
on 2010-10-15 at 11:19am EDT
**** (trbs) posted:
Without knowing about the ticket here I wrote my own, very simple version of the patch as described here.
My patch is a lot simpler then the one attached here, it only adds an option to disable/reject interactive password prompts.
It's still missing a command-line switch, but this shouldn't be hard to add :)
on 2011-03-09 at 01:48pm EST
Rick Harding (mitechie) posted:
Mathieu Drapeau wrote:
I tried to apply the patch but git is cranky. I'm using git 1.7, perhaps the patch was created on an older version. Can you rebase/recreate it from master?
on 2011-03-14 at 11:27am EDT
There's a patch for this (feature, test and docs) created by @glyphobet and me at the pycon sprint. It only implements aborting when there would otherwise be a password prompt. All the stuff above about bad connections is really feature #8 and not this issue.
Commits are here: https://github.com/brainsik/fabric
on 2011-03-15 at 12:14am EDT
Jeff Forcier (bitprophet) posted:
We should probably also extend this to work for other prompts-displayed-by-Fabric functionality like the "What host to connect to?" question. Basically, searching for
on 2011-03-15 at 10:58am EDT
Jeff Forcier (bitprophet) posted:
Implementing this for 1.1; obtained diff from the commits in Jeremy's pull request (thankfully they were at HEAD and consecutive) and manually applied to my 1.1 codebase:
on 2011-06-21 at 06:53pm EDT
pushed a commit
Aug 31, 2011
This was referenced
Feb 29, 2012
As I understand, abort-on-prompts only abort the task, but not skip the prompt.
Thanks for your hard work
@zhihuiFan I didn't find the solution for this when I post this. Maybe
On Mon, Oct 6, 2014 at 10:02 AM, zhihuiFan email@example.com wrote:
life is beautiful,
Here is my two patches files :
$ cat fabric-1.10-patch1.patch --- fabric/network.py +++ fabric/network.py @@ -526,9 +526,14 @@ # because ssh doesn't provide us with that info, and # env.key_filename may be a list of keys, so we can't know # which one raised the exception. Best not to try. + if env.warn_passphrase: + error_msg = 'warn_passphrase option was set and Passphrase detected for %s' % host + sys.stdout.write('***Warning*** '+error_msg + '\n') + raise NetworkError(error_msg, e) prompt = "[%s] Passphrase for private key" text = prompt % env.host_string - password = prompt_for_password(text) + if not env.warn_passphrase: + password = prompt_for_password(text) # Update env.password, env.passwords if empty set_password(user, host, port, password) # Ctrl-D / Ctrl-C for exit
$ cat fabric-1.10-patch2.patch --- fabric/state.py +++ fabric/state.py @@ -280,6 +280,12 @@ default=False, help="warn, instead of abort, when commands fail" ), + + make_option('--warn_passphrase', + action='store_true', + default=False, + help="warn, instead of abort, when a ssh key passphrase is asked" + ), make_option('-x', '--exclude-hosts', default=, @@ -353,7 +359,8 @@ 'use_shell': True, 'use_ssh_config': False, 'user': None, - 'version': get_version('short') + 'version': get_version('short'), + 'warn_passphrase': False, }) # Fill in exceptions settings
And with this, you can use the --warn_passphrase option :
$ fab --warn_passphrase -H ...