mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
mod/ssh-keys-import: do not import twice
This commit is contained in:
parent
042ff1cfda
commit
b22dfbfc94
1 changed files with 7 additions and 0 deletions
|
@ -40,6 +40,13 @@
|
|||
}
|
||||
|
||||
: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={
|
||||
$LogPrintExit2 warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \
|
||||
") is already available for user '" . $User . "'.") false;
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local FileName ("tmpfs/ssh-keys-import/key-" . [ $GetRandom20CharAlNum 6 ] . ".pub");
|
||||
/file/add name=$FileName contents=($Key . ", md5=" . $FingerPrintMD5);
|
||||
$WaitForFile $FileName;
|
||||
|
|
Loading…
Reference in a new issue