Enable SSH only if any keys exist
This commit is contained in:
parent
81d9bb74ee
commit
2494c55493
@ -18,6 +18,13 @@ def set_authorized_keys(keys):
|
||||
# Saves content of root's authorized_files
|
||||
with open(AUTHORIZED_KEYS, 'w') as f:
|
||||
f.write(keys)
|
||||
# Enable or disable SSH service
|
||||
if keys.strip():
|
||||
subprocess.run(['/sbin/rc-update', 'add', 'sshd', 'boot'])
|
||||
subprocess.run(['/sbin/service', 'sshd', 'start'])
|
||||
else:
|
||||
subprocess.run(['/sbin/service', 'sshd', 'stop'])
|
||||
subprocess.run(['/sbin/rc-update', 'del', 'sshd', 'boot'])
|
||||
|
||||
def is_wireguard_running():
|
||||
# Returns status of wg0 interface (inferred from existence of its config file)
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% block body %}
|
||||
<div class="setup-box">
|
||||
<h2>SSH klíče</h2>
|
||||
<p>Obsah souboru <em>authorized_hosts</em> uživatele root.</p>
|
||||
<p>Obsah souboru <em>authorized_keys</em> uživatele root.</p>
|
||||
<form id="update-ssh-keys" action="/update-ssh-keys" method="post">
|
||||
<textarea name="ssh-keys" id="ssh-keys">{{ authorized_keys }}</textarea>
|
||||
<input type="submit" value="Nastavit klíče">
|
||||
|
Loading…
Reference in New Issue
Block a user