Magellan Linux

Diff of /alx-src/branches/alxconf-060/functions/config_ssh_auth.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 330 by niro, Wed Sep 7 19:14:24 2005 UTC revision 342 by niro, Sun Oct 9 21:30:41 2005 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_ssh_auth.sh,v 1.3 2005-09-07 19:14:18 niro Exp $  # $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 $
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/ssh/ssh_host_key ]
7   then   then
8   echo -e ${COLOREDSTAR}"Generating SSH-Hostkey ..."   echo -e ${COLOREDSTAR}"Generating SSH-Hostkey ..."
# Line 21  gen_keys() { Line 22  gen_keys() {
22   fi   fi
23  }  }
24    
25  config_ssh_auth() {  config_ssh_auth()
26    {
27   local PUB_KEY_SERVER   local PUB_KEY_SERVER
28   local ID   local ID
29    
# Line 30  config_ssh_auth() { Line 31  config_ssh_auth() {
31   gen_keys   gen_keys
32    
33   # write the public key of the server to the host system   # write the public key of the server to the host system
34   PUB_KEY_SERVER="$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   PUB_KEY_SERVER="$(mysqldo "select public_key from ssh_auth_server where id=1;")"
  "select public_key from ssh_auth_server where id=1;")"  
35    
36   if [ -n "${PUB_KEY_SERVER}" ]   if [ -n "${PUB_KEY_SERVER}" ]
37   then   then
# Line 41  config_ssh_auth() { Line 41  config_ssh_auth() {
41   echo "${PUB_KEY_SERVER}" > $HOME/.ssh/authorized_keys   echo "${PUB_KEY_SERVER}" > $HOME/.ssh/authorized_keys
42   fi   fi
43    
   
44   # put the public key of the host into the db   # put the public key of the host into the db
45   ID=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ID=$(mysqldo "select serial from ssh_auth_clients where serial=${ALX_SERIAL};")
  "select serial from ssh_auth_clients where serial=${ALX_SERIAL};")  
46    
47   if [ -n "${ID}" ]   if [ -n "${ID}" ]
48   then   then
49   #run an update   # run an update
50   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "update ssh_auth_clients set public_key='$(< /etc/ssh/ssh_host_rsa_key.pub)' where serial=${ALX_SERIAL};"
  "update ssh_auth_clients set public_key='$(< /etc/ssh/ssh_host_rsa_key.pub)' where serial=${ALX_SERIAL};"  
51   else   else
52   #run an insert   # run an insert
53   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   mysqldo "insert into ssh_auth_clients(serial,public_key) values('${ALX_SERIAL}','$(< /etc/ssh/ssh_host_rsa_key.pub)')"
  "insert into ssh_auth_clients(serial,public_key) values('${ALX_SERIAL}','$(< /etc/ssh/ssh_host_rsa_key.pub)')"  
54   fi   fi
55  }  }

Legend:
Removed from v.330  
changed lines
  Added in v.342