mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-10-10 04:43:10 +02:00
work with expection
This commit is contained in:
@@ -101,14 +101,13 @@ if sys.argv[1] == "on":
|
|||||||
# check if SSH keys for root user need to be created
|
# check if SSH keys for root user need to be created
|
||||||
print()
|
print()
|
||||||
print("*** Checking root SSH keys")
|
print("*** Checking root SSH keys")
|
||||||
sshkeys_exist = subprocess.check_output("sudo ls /root/.ssh/id_rsa.pub | grep -c 'id_rsa.pub'", shell=True, universal_newlines=True)
|
try:
|
||||||
print(sshkeys_exist)
|
subprocess.call("sudo ls /root/.ssh/id_rsa.pub", shell=True)
|
||||||
if str(sshkeys_exist).count("1") == 0:
|
print("OK - root id_rsa.pub file exists")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
print("Generating root SSH keys ...")
|
print("Generating root SSH keys ...")
|
||||||
subprocess.call("sudo -u root ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N \"\"", shell=True)
|
subprocess.call("sudo -u root ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N \"\"", shell=True)
|
||||||
print("DONE")
|
print("DONE")
|
||||||
else:
|
|
||||||
print("OK - root id_rsa.pub file exists")
|
|
||||||
ssh_pubkey = subprocess.check_output("sudo cat /root/.ssh/id_rsa.pub", shell=True, universal_newlines=True)
|
ssh_pubkey = subprocess.check_output("sudo cat /root/.ssh/id_rsa.pub", shell=True, universal_newlines=True)
|
||||||
|
|
||||||
# make sure autossh is installed
|
# make sure autossh is installed
|
||||||
|
Reference in New Issue
Block a user