Compare commits
No commits in common. "b1e5992f0550d7e445ee9a0477cdae5b8a7507e7" and "69ce72aa7bcd86bd58577b8e7cba84b67f21d36f" have entirely different histories.
b1e5992f05
...
69ce72aa7b
9 changed files with 14 additions and 30 deletions
|
@ -1 +0,0 @@
|
||||||
{}
|
|
20
libs/ssh.py
20
libs/ssh.py
|
@ -1,23 +1,19 @@
|
||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
from hashlib import sha3_256
|
|
||||||
|
|
||||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
|
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
|
||||||
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, PublicFormat, NoEncryption
|
from cryptography.hazmat.primitives import serialization
|
||||||
|
|
||||||
|
|
||||||
def generate_ed25519_key_pair(secret):
|
def generate_ed25519_key_pair(secret):
|
||||||
privkey_bytes = Ed25519PrivateKey.from_private_bytes(secret)
|
privkey_bytes = Ed25519PrivateKey.from_private_bytes(secret)
|
||||||
|
|
||||||
nondeterministic_privatekey = privkey_bytes.private_bytes(
|
nondeterministic_privatekey = privkey_bytes.private_bytes(
|
||||||
encoding=Encoding.PEM,
|
encoding=serialization.Encoding.PEM,
|
||||||
format=PrivateFormat.OpenSSH,
|
format=serialization.PrivateFormat.OpenSSH,
|
||||||
encryption_algorithm=NoEncryption()
|
encryption_algorithm=serialization.NoEncryption()
|
||||||
).decode()
|
).decode()
|
||||||
|
|
||||||
# handle random 32bit number, occuring twice in a row
|
|
||||||
nondeterministic_bytes = b64decode(''.join(nondeterministic_privatekey.split('\n')[1:-2]))
|
nondeterministic_bytes = b64decode(''.join(nondeterministic_privatekey.split('\n')[1:-2]))
|
||||||
random_bytes = sha3_256(secret).digest()[0:4]
|
# handle random 32bit number, occuring twice in a row
|
||||||
deterministic_bytes = nondeterministic_bytes[:98] + random_bytes + random_bytes + nondeterministic_bytes[106:]
|
deterministic_bytes = nondeterministic_bytes[:98] + b'00000000' + nondeterministic_bytes[106:]
|
||||||
deterministic_privatekey = '\n'.join([
|
deterministic_privatekey = '\n'.join([
|
||||||
'-----BEGIN OPENSSH PRIVATE KEY-----',
|
'-----BEGIN OPENSSH PRIVATE KEY-----',
|
||||||
b64encode(deterministic_bytes).decode(),
|
b64encode(deterministic_bytes).decode(),
|
||||||
|
@ -25,8 +21,8 @@ def generate_ed25519_key_pair(secret):
|
||||||
])
|
])
|
||||||
|
|
||||||
public_key = privkey_bytes.public_key().public_bytes(
|
public_key = privkey_bytes.public_key().public_bytes(
|
||||||
encoding=Encoding.OpenSSH,
|
encoding=serialization.Encoding.OpenSSH,
|
||||||
format=PublicFormat.OpenSSH,
|
format=serialization.PublicFormat.OpenSSH,
|
||||||
).decode()
|
).decode()
|
||||||
|
|
||||||
return (deterministic_privatekey, public_key)
|
return (deterministic_privatekey, public_key)
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
'hostname': '10.0.0.5',
|
'hostname': '10.0.0.5',
|
||||||
'groups': [
|
'groups': [
|
||||||
'autologin',
|
|
||||||
'backup-server',
|
|
||||||
'debian-11',
|
'debian-11',
|
||||||
'home',
|
'backup-server',
|
||||||
'monitored',
|
'monitored',
|
||||||
|
'autologin',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'smartctl',
|
'smartctl',
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
{
|
{
|
||||||
'hostname': '10.0.2.8',
|
'hostname': '10.0.2.8',
|
||||||
'groups': [
|
'groups': [
|
||||||
'autologin',
|
|
||||||
'home',
|
|
||||||
'raspberrymatic',
|
'raspberrymatic',
|
||||||
|
'autologin',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'hostname',
|
'hostname',
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
{
|
{
|
||||||
'dummy': True,
|
'dummy': True,
|
||||||
'groups': [
|
|
||||||
'home',
|
|
||||||
],
|
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': '',
|
'id': '',
|
||||||
'network': {
|
'network': {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
{
|
{
|
||||||
'hostname': '10.0.0.17',
|
'hostname': '10.0.0.17',
|
||||||
'groups': [
|
'groups': [
|
||||||
'autologin',
|
|
||||||
'backup',
|
'backup',
|
||||||
'debian-11',
|
'debian-11',
|
||||||
'home',
|
|
||||||
'monitored',
|
'monitored',
|
||||||
'raspberry-pi',
|
'raspberry-pi',
|
||||||
'webserver',
|
'webserver',
|
||||||
|
'autologin',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'build-agent',
|
'build-agent',
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
{
|
{
|
||||||
'hostname': '10.0.0.2',
|
'hostname': '10.0.0.2',
|
||||||
'groups': [
|
'groups': [
|
||||||
'autologin',
|
|
||||||
'backup',
|
'backup',
|
||||||
'debian-11',
|
'debian-11',
|
||||||
'home',
|
|
||||||
'nextcloud',
|
'nextcloud',
|
||||||
'monitored',
|
'monitored',
|
||||||
'webserver',
|
'webserver',
|
||||||
'hardware',
|
'hardware',
|
||||||
'build-server',
|
'build-server',
|
||||||
|
'autologin',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'apcupsd',
|
'apcupsd',
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
'hostname': '10.0.0.15',
|
'hostname': '10.0.0.15',
|
||||||
'groups': [
|
'groups': [
|
||||||
'autologin',
|
|
||||||
'debian-11',
|
'debian-11',
|
||||||
'home',
|
|
||||||
'raspberry-pi',
|
'raspberry-pi',
|
||||||
'monitored',
|
'monitored',
|
||||||
|
'autologin',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'stromzaehler',
|
'stromzaehler',
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
{
|
{
|
||||||
'dummy': True,
|
'dummy': True,
|
||||||
'groups': [
|
|
||||||
'home',
|
|
||||||
],
|
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': '',
|
'id': '',
|
||||||
'network': {
|
'network': {
|
||||||
|
|
Loading…
Reference in a new issue