21 |
local PUB_KEY_SERVER |
local PUB_KEY_SERVER |
22 |
local ID |
local ID |
23 |
local pubkey |
local pubkey |
24 |
|
local CONFIG |
25 |
|
|
26 |
# generate evtually missing keys |
# generate evtually missing keys |
27 |
gen_keys |
gen_keys |
32 |
# write the public key of the server to the host system |
# write the public key of the server to the host system |
33 |
PUB_KEY_SERVER="$(mysqldo "select public_key from ssh_auth_server where id=1;")" |
PUB_KEY_SERVER="$(mysqldo "select public_key from ssh_auth_server where id=1;")" |
34 |
|
|
35 |
if [ -n "${PUB_KEY_SERVER}" ] |
if [[ ! -z ${PUB_KEY_SERVER} ]] |
36 |
then |
then |
37 |
HOME=/root |
HOME=/root |
38 |
# only if not empty |
# only if not empty |
39 |
[ ! -d $HOME/.ssh ] && install -d $HOME/.ssh |
[ ! -d $HOME/.ssh ] && install -d $HOME/.ssh |
40 |
echo "${PUB_KEY_SERVER}" > $HOME/.ssh/authorized_keys |
CONFIG=$HOME/.ssh/authorized_keys |
41 |
|
clearconfig |
42 |
|
addconfig "${PUB_KEY_SERVER}" |
43 |
fi |
fi |
44 |
|
|
45 |
# put the public key of the host into the db |
# put the public key of the host into the db |
46 |
ID=$(mysqldo "select serial from ssh_auth_clients where serial=${ALX_SERIAL};") |
ID=$(mysqldo "select serial from ssh_auth_clients where serial=${ALX_SERIAL};") |
47 |
|
|
48 |
if [ -n "${ID}" ] |
if [[ ! -z ${ID} ]] |
49 |
then |
then |
50 |
# run an update |
# run an update |
51 |
mysqldo "update ssh_auth_clients set public_key='${pubkey}' where serial=${ALX_SERIAL};" |
mysqldo "update ssh_auth_clients set public_key='${pubkey}' where serial=${ALX_SERIAL};" |