Comments (1)
def onConnectionPrompt(prompt, state, logger):
"""
:type prompt: str
:type state: dict[str, object]
:type logger: logging.Logger
:rtype: str|None
"""
prompt = prompt.lower()
state.setdefault('triedPassword', 0)
state.setdefault('triedKeys', {})
if 'enter passphrase for key' in prompt:
key = re.findall( r'key \'(.+)\':\s*$', prompt, flags = re.IGNORECASE | re.MULTILINE )
if key is None or len(key) != 1: key = '???'
else: key = key[0]
state['triedKeys'].setdefault(key, 0)
if state['triedKeys'][key] > 2:
logger.error('Connect failed: incorrect passphrase')
return None
else:
state['triedKeys'][key] += 1
state['triedPassword'] = 0
logger.debug('Trying key \'{}\''.format(key))
return state['passphrase']
if 'password:' in prompt:
if state['triedPassword'] > 2:
logger.error('Connect failed: incorrect password')
return None
else:
state['triedPassword'] += 1
state['triedKeys'] = {}
logger.debug('Trying password')
return state['password']
return None
from sisqo.
Related Issues (9)
- SSH._proxyCommand not initialized properly HOT 2
- authenticate() – re.match(...) -> re.findall(...)
- Maintaining prompt with consumeEcho=False/stripPrompt=False adds extraneous newline HOT 1
- Example code is out of date HOT 1
- "Password:" prompt matching can fail in rare circumstances
- Should log repr()'d value in these places HOT 1
- -oConnectTimeout=5 seems low when all other timeouts are 10
- Python 3 compatibility HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sisqo.