diff options
author | Christian Hesse <mail@eworm.de> | 2023-11-02 09:46:25 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-11-09 15:08:36 +0100 |
commit | 1265caca60bf097d66ef9ef0814e8f04f9720170 (patch) | |
tree | 2834fab4cf22b32bcf273e76efe4f6586be2cf15 /mod | |
parent | c3045f372350bd8dd0a8f10efb8a4b938e896145 (diff) |
mod/ssh-keys-import: calculate fingerprint...routeros-7.12beta1-2change-112
... and store it in key-owner, which is descriptive only.
This requires RouterOS 7.12beta1 for the 'transform' property
for ':convert' command.
Diffstat (limited to 'mod')
-rw-r--r-- | mod/ssh-keys-import.rsc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index fb6fee1..0e82785 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -3,6 +3,8 @@ # Copyright (c) 2020-2023 Christian Hesse <mail@eworm.de> # https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md # +# requires RouterOS, version=7.12beta1 +# # import ssh keys for public key authentication # https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/ssh-keys-import.md @@ -38,12 +40,15 @@ $LogPrintExit2 warning $0 ("Creating directory 'tmpfs/ssh-keys-import' failed!") true; } + :local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex ($KeyVal->1) ]; :local FileName ("tmpfs/ssh-keys-import/key-" . [ $GetRandom20CharAlNum 6 ] . ".pub"); - /file/add name=$FileName contents=$Key; + /file/add name=$FileName contents=($Key . ", md5=" . $FingerPrintMD5); $WaitForFile $FileName; :do { /user/ssh-keys/import public-key-file=$FileName user=$User; + $LogPrintExit2 info $0 ("Imported ssh public key (" . $KeyVal->2 . ", " . $KeyVal->0 . ", " . \ + "MD5:" . $FingerPrintMD5 . ") for user '" . $User . "'.") false; } on-error={ $LogPrintExit2 warning $0 ("Failed importing key.") true; } |