mrblacyk / Boxer

Boxer is a self-hosted platform for managing boxes (VMs). Some say it's open-source HackTheBox platform.
Apache License 2.0
19 stars 7 forks source link

Configurable libvirt URI #3

Open mrblacyk opened 4 years ago

mrblacyk commented 4 years ago

Right now code in aplibvirt.py is:

def connect(URI: str = "qemu:///system") -> libvirt.virConnect:
    """ Simple libvirt connect function """

    return libvirt.open(URI)

So it's ready to consume different URI.

What needs to be done:

  1. Make it dependant on some configuration from database
  2. Create proper webpage for it under sysadmin tools (maybe a general settings page which will include this particular settings?)
mrblacyk commented 4 years ago

On it.

mrblacyk commented 4 years ago

Next step is to create a private RSA key and store it in the database using this snippet:

from paramiko import RSAKey
from io import StringIO

# Generate key and make a string out of it
key = RSAKey.generate(4096)
pkey = StringIO()
key.write_private_key(pkey)
pkey_string = pkey.getvalue()  # Store in DB

# Make a RSA key out of string
key2 = RSAKey.from_private_key(pkey_string)
public_b64 = key2.get_base64()  # This part for authorized_keys file
mrblacyk commented 4 years ago

Overall, the idea is to create a wizard to establish qemu+libssh2:// communication to a hypervisor host so the application can be dockerized

mrblacyk commented 4 years ago

For now, passing /var/run/libvirt/libvirt-sock socket to docker must be enough.