Skip to content

Commit 1f5cd1b

Browse files
committed
better authentication failure handling
1 parent 92540a8 commit 1f5cd1b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

soloutils/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ def _connect(ip, await=True, silent=False):
2929
socket.setdefaulttimeout(5)
3030
message = silent
3131
start = time.time()
32+
tryCount = 0
3233
while True:
34+
35+
if (tryCount >= 5):
36+
print 'error: unable to connect after {} attempts, giving up.'.format(tryCount)
37+
sys.exit(1)
38+
39+
tryCount = tryCount + 1
40+
3341
try:
3442
client.connect(ip, username='root', password='TjSDBkAu', timeout=5)
3543
except paramiko.BadHostKeyException:
@@ -39,6 +47,9 @@ def _connect(ip, await=True, silent=False):
3947
print ''
4048
print 'and try again'
4149
sys.exit(1)
50+
except paramiko.AuthenticationException as e:
51+
print 'ssh authentication error'
52+
raise e
4253
except Exception as e:
4354
if not await:
4455
raise e

0 commit comments

Comments
 (0)