It 100% is working in the terminal, though it must be hardcoded values. This garbage scripting language seems to be unable to interpolate the variable on that line.
No other part of the script is of note or an issue.
I like the ; at end, and the ""'s I added to try to make it interpolate.
I will just hardcode the values for this garbage OS.
e.g. /ip ssh export-host-key key-file-prefix="$sshHostKeyPrefix" passhprase="$sshHostKeyPassphrase"; doesn't work and /ip ssh export-host-key key-file-prefix="ssh/somepath" passphrase="somepassphrase"; does.
Now I am getting the same error with the typo corrected, but the command really does run on the CLI now. Can I share a screenshot
entire current script:
# :global sshHostKeyFile;
# :global sshHostKeyPassphrase;
# :global sshAdminPubKey;
:local sshHostKeyPrefix "rb5009_host";
# don't use $, ", or ? in passphrases
:local sshHostKeyPassphrase "password";
:local sshAdminPubKey "ssh/rb5009_admin_ed25519.pub";
# don't use $, ", or ? in passphrases
:local sshAdminPubKeyPassphrase "password";
/ip ssh set host-key-type=ed25519;
# only used for rsa, but set to max anyways
/ip ssh set host-key-size=8192;
/ip ssh set strong-crypto=yes;
:put "regenerate and backup host ssh keys in correct format";
/ip ssh regenerate-host-key;
/ip ssh export-host-key key-file-prefix=$sshHostKeyPrefix passphrase=$sshHostKeyPassphrase;
:put "importing admin key"
/user ssh-keys import public-key-file=$sshAdminPubKey user=username;
This work for sure both on terminal and script, and I have tested that on 7.16.2.
I do not have any device at home now for test on 7.20.6
{
:local hkPref "rb5009_host"
# use \ for use $, ", or ? in passphrases
:local hkPass "pa\$\$word"
/ip ssh set host-key-type=ed25519
/ip ssh set host-key-size=8192
/ip ssh set strong-crypto=yes
/ip ssh regenerate-host-key
/ip ssh export-host-key key-file-prefix=$hkPref passphrase=$hkPass
}
I added that code, and removed my code, but I get the exact same error still.
Is there a reason removing a file and re-uploading a file would be a problem?
The only thing I can think right now is that I have kept referencing some wrong version, and get the same error because there are only 14 lines in your code, and I am getting the same line 19 error.
Steps: remove old script, upload new script, run. but getting old error
Aside from the fact that I obviously commented out the last line,
your version also works for me without errors,
both when running the script and when pasting into the terminal.