mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-03-04 21:19:36 +00:00
Compare commits
4 commits
48d0f1f0b9
...
c81618b571
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c81618b571 | ||
|
|
35b556f0b2 | ||
|
|
9ceed0926a | ||
|
|
5ffa85f8bf |
4 changed files with 19 additions and 7 deletions
|
|
@ -38,8 +38,9 @@ import that key:
|
|||
$SSHKeysImport "ssh-rsa AAAAB3Nza...QYZk8= user" admin;
|
||||
|
||||
The third part of the key (`user` in this example) is inherited as
|
||||
`key-owner` in RouterOS. Also the `MD5` fingerprint is recorded, this helps
|
||||
to audit and verify the available keys.
|
||||
`key-owner` in RouterOS (or `info` starting with RouterOS 7.21beta2). Also
|
||||
the `MD5` fingerprint is recorded, this helps to audit and verify the
|
||||
available keys.
|
||||
|
||||
> ℹ️️ **Info**: Use `ssh-keygen` to show a fingerprint of an existing public
|
||||
> key file: `ssh-keygen -l -E md5 -f ~/.ssh/id_ed25519.pub`
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
:global LogPrint;
|
||||
:global LogPrintOnce;
|
||||
:global LogPrintVerbose;
|
||||
:global MIN;
|
||||
:global ScriptLock;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
|
|
@ -111,22 +112,30 @@
|
|||
:set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr"));
|
||||
}
|
||||
:do {
|
||||
:local Branch [ $GetBranch $Address ];
|
||||
:local Branch;
|
||||
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
|
||||
:if ($Address ~ "/32\$") do={
|
||||
:set Address [ :pick $Address 0 ([ :len $Address ] - 3) ];
|
||||
}
|
||||
:set Branch [ $GetBranch $Address ];
|
||||
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
||||
:error true;
|
||||
}
|
||||
:if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
|
||||
:if ([ :typeof [ :find $Address "/" ] ] = "nil") do={
|
||||
:set Address ($Address . "/128");
|
||||
:local Net $Address;
|
||||
:local Cidr 64;
|
||||
:local Slash [ :find $Address "/" ];
|
||||
:if ([ :typeof $Slash ] = "num") do={
|
||||
:set Net [ :toip6 [ :pick $Address 0 $Slash ] ]
|
||||
:set Cidr [ $MIN [ :pick $Address ($Slash + 1) [ :len $Address ] ] 64 ];
|
||||
}
|
||||
:set Address (([ :toip6 $Net ] & ffff:ffff:ffff:ffff::) . "/" . $Cidr);
|
||||
:set Branch [ $GetBranch $Address ];
|
||||
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
|
||||
:error true;
|
||||
}
|
||||
:if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
|
||||
:set Branch [ $GetBranch $Address ];
|
||||
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
||||
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
|
||||
:error true;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@
|
|||
:set LogForwardRateLimit ($LogForwardRateLimit + 10);
|
||||
|
||||
$SendNotification2 ({ origin=$ScriptName; \
|
||||
subject=([ $SymbolForNotification [ $IfThenElse ($Warning = true) "warning-sign" "memo" ] ] . \
|
||||
subject=([ $SymbolForNotification ("memo" . [ $IfThenElse ($Warning = true) ",warning-sign" ]) ] . \
|
||||
"Log Forwarding"); \
|
||||
message=("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) "this message" \
|
||||
("these " . $Count . " messages") ] . " after " . [ /system/resource/get uptime ] . " uptime." . \
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@
|
|||
|
||||
:local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex ($KeyVal->1) ];
|
||||
|
||||
:if ([ :len [ /user/ssh-keys/find where user=$User key-owner~("\\bmd5=" . $FingerPrintMD5 . "\\b") ] ] > 0) do={
|
||||
:local RegEx ("\\bmd5=" . $FingerPrintMD5 . "\\b");
|
||||
:if ([ :len [ /user/ssh-keys/find where user=$User \
|
||||
(key-owner~$RegEx or info~$RegEx) ] ] > 0) do={
|
||||
$LogPrint warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \
|
||||
") is already available for user '" . $User . "'.");
|
||||
:return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue