1 |
# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_ssh_auth.sh,v 1.4 2005-10-09 21:30:41 niro Exp $ |
# $Id$ |
2 |
# exchanges the public server and client ssh keys |
# exchanges the public server and client ssh keys |
3 |
|
|
4 |
gen_keys() |
gen_keys() |
5 |
{ |
{ |
6 |
if [ ! -e /etc/ssh/ssh_host_key ] |
if [ ! -e /etc/dropbear/dropbear_dss_host_key ] |
7 |
then |
then |
8 |
echo -e ${COLOREDSTAR}"Generating SSH-Hostkey ..." |
echo -e ${COLOREDSTAR}"Generating DSS-Hostkey ..." |
9 |
/usr/bin/ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N '' |
dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key |
10 |
fi |
fi |
11 |
|
|
12 |
if [ ! -e /etc/ssh/ssh_host_dsa_key ] |
if [ ! -e /etc/dropbear/dropbear_rsa_host_key ] |
13 |
then |
then |
14 |
echo -e ${COLREDSTAR}"Generating DSA-Hostkey ..." |
echo -e ${COLREDSTAR}"Generating RSA-Hostkey ..." |
15 |
/usr/bin/ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N '' |
dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key |
|
fi |
|
|
|
|
|
if [ ! -e /etc/ssh/ssh_host_rsa_key ] |
|
|
then |
|
|
echo -e ${COLOREDSTAR}"Generating RSA-Hostkey ..." |
|
|
/usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' |
|
16 |
fi |
fi |
17 |
} |
} |
18 |
|
|
20 |
{ |
{ |
21 |
local PUB_KEY_SERVER |
local PUB_KEY_SERVER |
22 |
local ID |
local ID |
23 |
|
local pubkey |
24 |
|
|
25 |
# generate evtually missing keys |
# generate evtually missing keys |
26 |
gen_keys |
gen_keys |
27 |
|
|
28 |
|
# read the pubkey (the sed prints only the second line, which is the pubkey) |
29 |
|
pubkey="$(dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key | sed -n '2p')" |
30 |
|
|
31 |
# write the public key of the server to the host system |
# write the public key of the server to the host system |
32 |
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;")" |
33 |
|
|
45 |
if [ -n "${ID}" ] |
if [ -n "${ID}" ] |
46 |
then |
then |
47 |
# run an update |
# run an update |
48 |
mysqldo "update ssh_auth_clients set public_key='$(< /etc/ssh/ssh_host_rsa_key.pub)' where serial=${ALX_SERIAL};" |
mysqldo "update ssh_auth_clients set public_key='${pubkey}' where serial=${ALX_SERIAL};" |
49 |
else |
else |
50 |
# run an insert |
# run an insert |
51 |
mysqldo "insert into ssh_auth_clients(serial,public_key) values('${ALX_SERIAL}','$(< /etc/ssh/ssh_host_rsa_key.pub)')" |
mysqldo "insert into ssh_auth_clients(serial,public_key) values('${ALX_SERIAL}','${pubkey}')" |
52 |
fi |
fi |
53 |
} |
} |