Warning

This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy_test.base.ssh_util

import collections
import tempfile

from Crypto.PublicKey import RSA


[docs]def generate_ssh_keys(): """Returns a named tuple with private and public key and their paths.""" key = RSA.generate(2048) private_key = key.export_key() public_key = key.publickey().export_key(format='OpenSSH') ssh_keys = collections.namedtuple('SSHKeys', 'private_key public_key private_key_file public_key_file') with tempfile.NamedTemporaryFile(delete=False) as f: f.write(private_key) private_key_file = f.name with tempfile.NamedTemporaryFile(delete=False) as f: f.write(public_key) public_key_file = f.name return ssh_keys(private_key, public_key, private_key_file, public_key_file)