Skip to content

Commit 50223b3

Browse files
committed
Ignore errors "p/q must be exactly ..." when attempting SSH connections.
This is due to a bug in Paramiko, see paramiko/paramiko#750 and paramiko/paramiko#1606
1 parent fcd809a commit 50223b3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎elasticluster/cluster.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env python
22
#
3+
# Copyright (C) 2021 Google LLC
34
# Copyright (C) 2013-2019 University of Zurich
45
#
56
# This program is free software: you can redistribute it and/or modify
@@ -30,14 +31,15 @@
3031
from copy import copy
3132
from functools import reduce
3233
import itertools
34+
from multiprocessing.dummy import Pool
3335
import operator
3436
import os
3537
import re
3638
import signal
3739
import socket
3840
import sys
3941
import time
40-
from multiprocessing.dummy import Pool
42+
from warnings import warn
4143

4244
# External modules
4345
import paramiko
@@ -1465,6 +1467,18 @@ def connect(self, keyfile=None, timeout=5):
14651467
log.debug(
14661468
"Ignoring error connecting to %s: %s -- %r",
14671469
self.name, ex, type(ex))
1470+
except ValueError as err:
1471+
msg = str(err)
1472+
if msg.startswith("q must be exactly") or msg.startswith("p must be exactly"):
1473+
# warn and continue, this is just Paramiko mistakenly using an RSA
1474+
# key as DSA one, see: https://github.com/paramiko/paramiko/pull/1606
1475+
warn(
1476+
"The configured SSH private RSA key file `{0}`"
1477+
" can also be mistakenly read as a DSA key file."
1478+
" If you run into SSH connection problems, use"
1479+
" a different key.")
1480+
else:
1481+
raise
14681482

14691483
return None
14701484

0 commit comments

Comments
 (0)