30 lines
651 B
Bash
30 lines
651 B
Bash
#!/bin/sh
|
|
#
|
|
# DOCS:
|
|
# https://docs.fortinet.com/document/fortigate/7.2.4/administration-guide/813125/public-key-ssh-access
|
|
#
|
|
set -e
|
|
|
|
ssh_pubkey="/root/.ssh/id_ed25519.pub"
|
|
ssh_keytype="ed25519"
|
|
ssh_user="admin"
|
|
ssh_host="${ssh_user}@192.168.2.1"
|
|
ssh_opts="-p 11422"
|
|
|
|
. util.sh # import ssh function after options are set
|
|
|
|
ssh_pubkey_data=$(cut -f2 -d' ' < "$ssh_pubkey") # cut: only keydata is needed
|
|
|
|
fg_updatekey_script="
|
|
execute batch start
|
|
config system admin
|
|
edit ${ssh_user}
|
|
set ssh-public-key1 \"${ssh_keytype} ${ssh_pubkey_data}\"
|
|
next
|
|
end
|
|
execute batch end
|
|
execute batch lastlog
|
|
"
|
|
|
|
run_ssh_script "${fg_updatekey_script}"
|