diff options
author | James Falcon <TheRealFalcon@users.noreply.github.com> | 2020-12-03 16:41:46 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 17:41:46 -0500 |
commit | 06f7b4522aaa2f5c7f773f42f6c88aed50bb00d5 (patch) | |
tree | 3a9d38e0a8f5635d10347bcfa91ea5b2c96fa9f8 /tests/integration_tests/bugs | |
parent | 6c4e87bf336073183f8ae8964366d574c7ee4823 (diff) | |
download | vyos-cloud-init-06f7b4522aaa2f5c7f773f42f6c88aed50bb00d5.tar.gz vyos-cloud-init-06f7b4522aaa2f5c7f773f42f6c88aed50bb00d5.zip |
Integration test for pull #586 (#706)
If a non-default AuthorizedKeysFile is specified in
/etc/ssh/sshd_config, ensure we can still ssh as expected
Diffstat (limited to 'tests/integration_tests/bugs')
-rw-r--r-- | tests/integration_tests/bugs/test_gh586.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/integration_tests/bugs/test_gh586.py b/tests/integration_tests/bugs/test_gh586.py new file mode 100644 index 00000000..44b643f1 --- /dev/null +++ b/tests/integration_tests/bugs/test_gh586.py @@ -0,0 +1,42 @@ +"""Integration test for pull #586 + +If a non-default AuthorizedKeysFile is specified in /etc/ssh/sshd_config, +ensure we can still ssh as expected. +""" +import paramiko +import pytest +from io import StringIO +from tests.integration_tests.assets import get_test_rsa_keypair + + +public_rsa_key, private_rsa_key = get_test_rsa_keypair() +USER_DATA = """\ +#cloud-config +bootcmd: + - sed -i 's/#AuthorizedKeysFile.*/AuthorizedKeysFile\\ .ssh\\/authorized_keys2/' /etc/ssh/sshd_config +ssh_authorized_keys: + - {public_key} +""".format(public_key=public_rsa_key) # noqa: E501 + + +@pytest.mark.sru_2020_11 +@pytest.mark.user_data(USER_DATA) +def test_non_default_authorized_keys(client): + sshd = client.read_from_file('/etc/ssh/sshd_config') + assert 'AuthorizedKeysFile .ssh/authorized_keys2' in sshd + assert sshd.count('AuthorizedKeysFile') == 1 + + ssh_dir = client.execute('ls /home/ubuntu/.ssh').stdout + assert 'authorized_keys2' in ssh_dir + + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + paramiko_key = paramiko.RSAKey.from_private_key(StringIO(private_rsa_key)) + + # Will fail with paramiko.ssh_exception.AuthenticationException + # if this bug isn't fixed + ssh.connect( + client.instance.ip, + username=client.instance.username, + pkey=paramiko_key, + ) |