summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-system/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-system/luasrc')
-rw-r--r--modules/luci-mod-system/luasrc/controller/admin/system.lua53
-rw-r--r--modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm46
2 files changed, 1 insertions, 98 deletions
diff --git a/modules/luci-mod-system/luasrc/controller/admin/system.lua b/modules/luci-mod-system/luasrc/controller/admin/system.lua
index b9785994ad..be00a3f678 100644
--- a/modules/luci-mod-system/luasrc/controller/admin/system.lua
+++ b/modules/luci-mod-system/luasrc/controller/admin/system.lua
@@ -17,8 +17,7 @@ function index()
if fs.access("/etc/config/dropbear") then
entry({"admin", "system", "admin", "dropbear"}, cbi("admin_system/dropbear"), _("SSH Access"), 2)
- entry({"admin", "system", "admin", "sshkeys"}, template("admin_system/sshkeys"), _("SSH-Keys"), 3)
- entry({"admin", "system", "admin", "sshkeys", "json"}, post_on({ keys = true }, "action_sshkeys"))
+ entry({"admin", "system", "admin", "sshkeys"}, view("system/sshkeys"), _("SSH-Keys"), 3)
end
entry({"admin", "system", "startup"}, view("system/startup"), _("Startup"), 45)
@@ -293,56 +292,6 @@ function action_password()
luci.http.write_json({ code = luci.sys.user.setpasswd("root", password) })
end
-function action_sshkeys()
- local keys = luci.http.formvalue("keys")
- if keys then
- keys = luci.jsonc.parse(keys)
- if not keys or type(keys) ~= "table" then
- luci.http.status(400, "Bad Request")
- return
- end
-
- local fd, err = io.open("/etc/dropbear/authorized_keys", "w")
- if not fd then
- luci.http.status(503, err)
- return
- end
-
- local _, k
- for _, k in ipairs(keys) do
- if type(k) == "string" and k:match("^%w+%-") then
- fd:write(k)
- fd:write("\n")
- end
- end
-
- fd:close()
- end
-
- local fd, err = io.open("/etc/dropbear/authorized_keys", "r")
- if not fd then
- luci.http.status(503, err)
- return
- end
-
- local rv = {}
- while true do
- local ln = fd:read("*l")
- if not ln then
- break
- elseif ln:match("^[%w%-]+%s+[A-Za-z0-9+/=]+$") or
- ln:match("^[%w%-]+%s+[A-Za-z0-9+/=]+%s")
- then
- rv[#rv+1] = ln
- end
- end
-
- fd:close()
-
- luci.http.prepare_content("application/json")
- luci.http.write_json(rv)
-end
-
function action_reboot()
luci.sys.reboot()
end
diff --git a/modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm b/modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm
deleted file mode 100644
index ac453f3f6c..0000000000
--- a/modules/luci-mod-system/luasrc/view/admin_system/sshkeys.htm
+++ /dev/null
@@ -1,46 +0,0 @@
-<%+header%>
-
-<style type="text/css">
- .cbi-dynlist {
- max-width: 100%;
- }
-
- .cbi-dynlist .item > small {
- display: block;
- direction: rtl;
- overflow: hidden;
- text-align: left;
- }
-
- .cbi-dynlist .item > small > code {
- direction: ltr;
- white-space: nowrap;
- unicode-bidi: bidi-override;
- }
-
- @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
- .cbi-dynlist .item > small { direction: ltr }
- }
-</style>
-
-<div class="cbi-map">
- <h2><%:SSH-Keys%></h2>
-
- <div class="cbi-section-descr">
- <%_Public keys allow for the passwordless SSH logins with a higher security compared to the use of plain passwords. In order to upload a new key to the device, paste an OpenSSH compatible public key line or drag a <code>.pub</code> file into the input field.%>
- </div>
-
- <div class="cbi-section-node">
- <div class="cbi-dynlist" name="sshkeys">
- <p class="spinning"><%:Loading SSH keys…%></p>
- <div class="add-item" ondragover="dragKey(event)" ondrop="dropKey(event)">
- <input class="cbi-input-text" type="text" placeholder="<%:Paste or drag SSH key file…%>" onkeydown="if (event.keyCode === 13) addKey(event)" />
- <button class="cbi-button" onclick="addKey(event)"><%:Add key%></button>
- </div>
- </div>
- </div>
-</div>
-
-<script type="application/javascript" src="<%=resource%>/view/system/sshkeys.js"></script>
-
-<%+footer%>