Skip to content

Commit d83f98b

Browse files
committed
T7557: Workaround for upstream paramiko bug
1 parent 8f8ad81 commit d83f98b

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

debian/vyos-1x.postinst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,7 @@ fi
278278
if systemctl is-active --quiet vyos-domain-resolver; then
279279
systemctl restart vyos-domain-resolver
280280
fi
281+
282+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1108434
283+
sed -i 's/OpenSSH_(?:\[1-6\]|/OpenSSH_(?:[1-6]\\.|/g' /usr/lib/python3/dist-packages/paramiko/auth_handler.py
284+
rm -rf /usr/lib/python3/dist-packages/paramiko/__pycache__

smoketest/scripts/cli/base_vyostest_shim.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,19 @@ def getFRRconfig(self, string=None, end='$', endsection='^!',
153153

154154
@staticmethod
155155
def ssh_send_cmd(command, username, password, key_filename=None,
156-
hostname='localhost'):
156+
hostname='localhost', certificate=None):
157157
""" SSH command execution helper """
158158
# Try to login via SSH
159159
ssh_client = paramiko.SSHClient()
160160
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
161+
pkey = None
162+
if key_filename:
163+
with open(key_filename, 'r') as f:
164+
pkey = paramiko.RSAKey.from_private_key(f)
165+
if certificate:
166+
pkey.load_certificate(certificate)
161167
ssh_client.connect(hostname=hostname, username=username,
162-
password=password, key_filename=key_filename)
168+
password=password, pkey=pkey)
163169
_, stdout, stderr = ssh_client.exec_command(command)
164170
output = stdout.read().decode().strip()
165171
error = stderr.read().decode().strip()

smoketest/scripts/cli/test_service_ssh.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,13 @@ def test_ssh_trusted_user_ca(self):
449449

450450
# Verify functionality by logging into the system using signed user key
451451
key_filename = f'/tmp/{test_user}'
452+
user_cert_str = cert_user_signed.replace('\n', '')
452453
write_file(key_filename, cert_user_key, mode=0o600)
453-
write_file(f'{key_filename}-cert.pub', cert_user_signed.replace('\n', ''))
454454

455455
# Login with proper credentials
456456
output, error = self.ssh_send_cmd(test_command, test_user, password=None,
457-
key_filename=key_filename)
457+
key_filename=key_filename,
458+
certificate=user_cert_str)
458459
# Verify login
459460
self.assertFalse(error)
460461
self.assertEqual(output, cmd(test_command))
@@ -471,7 +472,8 @@ def test_ssh_trusted_user_ca(self):
471472

472473
# Login with proper credentials
473474
output, error = self.ssh_send_cmd(test_command, test_user, password=None,
474-
key_filename=key_filename)
475+
key_filename=key_filename,
476+
certificate=user_cert_str)
475477
# Verify login
476478
self.assertFalse(error)
477479
self.assertEqual(output, cmd(test_command))

0 commit comments

Comments
 (0)