Files
ssh-proxy/gen.lua
2025-11-27 00:00:11 +02:00

32 lines
757 B
Lua

local conf, out = ...;
local f = assert(io.open(out, "w"));
local i = 0;
f:write("AllowAgentForwarding yes\n");
for l in io.lines(conf) do
i = i + 1;
l = l:match "^(.-)#" or l;
l = l:match "^%s*(.-)%s*$";
if l ~= "" then
local user, params = l:match "^([%a_]+)%s+=%s+(.*)$";
if not user then
error(conf .. ":" .. i .. ": invalid syntax", 0);
end
os.execute("adduser -Ds /bin/sh " .. user);
os.execute("passwd -d " .. user);
f:write("Match User ", user);
f:write("\n\tForceCommand ssh-agent ssh -o StrictHostKeyChecking=no ", params, " $SSH_ORIGINAL_COMMAND $SSH_AUTH_SOCK");
f:write("\n\tPubkeyAuthentication yes");
f:write("\n\tPasswordAuthentication yes");
f:write("\n\tPermitEmptyPasswords yes\n");
end
end
f:close();