aboutsummaryrefslogtreecommitdiffstats
path: root/testing/aaudit/aaudit-update-keys
blob: 3521808cbac708cbd5f1fec6c51f19f35ad76ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/lua5.2

local posix = require 'posix'
local aac = require 'aaudit.common'

local home = os.getenv("HOME")
local allkeys = {}
for _, keyfile in ipairs(posix.glob(("%s/keydir/*.pub"):format(home))) do
	local identity = keyfile:match("keydir/(.*).pub$")
	for sshkey in io.lines(keyfile) do
		table.insert(allkeys,
			('command="/usr/libexec/aaudit/aaudit-shell %s"'..
			 ',no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s\n')
			:format(identity, sshkey))
	end
end

aac.writefile(table.concat(allkeys), ("%s/.ssh/authorized_keys"):format(home))