Skip to content

Commit

Permalink
Merge pull request #93 from UISSH/develop
Browse files Browse the repository at this point in the history
Fixed bug
  • Loading branch information
zmaplex committed Jun 30, 2023
2 parents 90802be + 1f196e6 commit 2fb9121
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests

# Don't add v prefix
CURRENT_VERSION = "0.2.8"
CURRENT_VERSION = "0.2.9"
FRONTED_MINIMUM_VERSION = "0.2.7"

resp = requests.get("https://ischina.org/")
Expand Down
12 changes: 10 additions & 2 deletions websocket/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import logging
from io import StringIO
import os

import paramiko


logger = logging.getLogger(__name__)

folder = "/usr/local/uissh/data"


def mkdir_data():
if not os.path.exists(folder):
os.makedirs(folder)


def generate_ssh_key():
"""
Expand All @@ -20,13 +28,13 @@ def generate_ssh_key():
logging.info("generate ssh key...")
key = paramiko.RSAKey.generate(4096)
pub = key.get_base64()
key.write_private_key_file("./uissh.pem")
key.write_private_key_file(f"{folder}/uissh.pem")
append_data = f'from="127.0.0.1" ssh-rsa {pub} by_uissh\n\n'
with open("/root/.ssh/authorized_keys", "w") as f:
f.write(append_data + old_data)

return {
"pkey": paramiko.RSAKey.from_private_key(open("./uissh.pem")),
"pkey": paramiko.RSAKey.from_private_key(open(f"{folder}/uissh.pem")),
"username": "root",
"hostname": "localhost",
}
Expand Down

0 comments on commit 2fb9121

Please sign in to comment.