Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull public ssh key from file. #249

Merged
merged 2 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ Requirements
- azure-mgmt-compute
- azure-mgmt-network
- azure-mgmt-resource
- certifi
- Click
- cryptography
- paramiko
- pycryptodome
- pytest
- PyYaml
- testinfra
Expand Down
3 changes: 0 additions & 3 deletions docs/source/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ Requirements
- azure-mgmt-compute
- azure-mgmt-network
- azure-mgmt-resource
- certifi
- Click
- cryptography
- paramiko
- pycryptodome
- pytest
- PyYaml
- testinfra
Expand Down
28 changes: 7 additions & 21 deletions img_proof/ipa_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
from img_proof.ipa_constants import SYNC_POINTS
from img_proof.ipa_exceptions import IpaSSHException, IpaUtilsException

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization

CLIENT_CACHE = {}


Expand Down Expand Up @@ -195,30 +192,19 @@ def generate_instance_name(name):

def generate_public_ssh_key(ssh_private_key_file):
smarlowucf marked this conversation as resolved.
Show resolved Hide resolved
"""Generate SSH public key from private key file."""
pub_key = ssh_private_key_file + '.pub'

try:
with open(ssh_private_key_file, "rb") as key_file:
with open(pub_key, "rb") as key_file:
key = key_file.read()
except FileNotFoundError:
raise IpaUtilsException(
'SSH private key file: %s cannot be found.' % ssh_private_key_file
)

try:
private_key = serialization.load_pem_private_key(
key,
password=None,
backend=default_backend()
)
except ValueError:
raise IpaUtilsException(
'SSH private key file: %s is not a valid key file.'
% ssh_private_key_file
'SSH public key file: {key_path} cannot be found.'.format(
key_path=pub_key
)
)

return private_key.public_key().public_bytes(
serialization.Encoding.OpenSSH,
serialization.PublicFormat.OpenSSH
)
return key


def get_config_values(config_path, section, default='default'):
Expand Down
6 changes: 0 additions & 6 deletions package/python3-img-proof.spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ BuildRequires: python3-azure-mgmt-compute
BuildRequires: python3-azure-mgmt-network
BuildRequires: python3-azure-mgmt-resource
BuildRequires: python3-boto3
BuildRequires: python3-certifi
BuildRequires: python3-click
BuildRequires: python3-cryptography
BuildRequires: python3-google-api-python-client
BuildRequires: python3-google-auth
BuildRequires: python3-oci-sdk
BuildRequires: python3-paramiko
BuildRequires: python3-pycryptodome
BuildRequires: python3-pytest
BuildRequires: python3-testinfra
%if %{with test}
Expand All @@ -54,14 +51,11 @@ Requires: python3-azure-mgmt-compute
Requires: python3-azure-mgmt-network
Requires: python3-azure-mgmt-resource
Requires: python3-boto3
Requires: python3-certifi
Requires: python3-click
Requires: python3-cryptography
Requires: python3-google-api-python-client
Requires: python3-google-auth
Requires: python3-oci-sdk
Requires: python3-paramiko
Requires: python3-pycryptodome
Requires: python3-pytest
Requires: python3-testinfra
BuildArch: noarch
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ azure-common
azure-mgmt-compute
azure-mgmt-network
azure-mgmt-resource
certifi
Click
cryptography
paramiko
pycryptodome
pytest
PyYAML
testinfra
Expand Down
1 change: 1 addition & 0 deletions tests/data/ida_test.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjo9ZkUp/dKKVButD+yaDkcWt4goSysXqibMoMedCp1GiKBXA6aeCY8eaenGTxo0fhIVyDX6QyNpE6OP5TYb7emrf7ze7OW2TvtxNZJOoGeT6e7rE/GzvM7UKxUVOl/h1TQ6oASD8nFQgVqjxpaALfouk0lPyBDS0WgvIGUYffYYHQaxzwebhs4ZpcBU3VYJTRFdecw0QzAakSOsUZyMWZUS7GzGR9NfoBf7H3AYp5rcbVOncFnFDZGAZxMJ65I18yU7RsLzaSzBgpUGmhEGaUHhRwGsLT+y+0oO2ftiIGgnYWa1cMDsrWypTm1gSI8+ivHZkmHI9PUDlDzrAQ4FmP