Commit 05272f95 authored by Christopher Alfeld's avatar Christopher Alfeld

Some very hackish scripts for storing host keys in the DB. These should

all be replaced by perl scripts soon.

gethostkey.tcl - Takes a node # and queries it for the host key, encodes
it, and puts it in the DB.

hostkey.tcl - Extracts a hostkey from the DB and decodes it.

key*.c - Encoding/decoding programs.
parent a3d88084
CC=gcc
CFLAGS=-O
all: key7 key8
key7: key7.c
$(CC) $(CFLAGS) -o key7 key7.c
key8: key8.c
$(CC) $(CFLAGS) -o key8 key8.c
#!/usr/local/bin/tclsh
set sdir [file dirname [info script]]
if {[file dirname [info script]] == "."} {
load ../lib/sql.so
} else {
load [file dirname [file dirname [info script]]]/lib/sql.so
}
if {[llength $argv] != 1} {
puts stderr "Syntax: $argv0 <node#>"
exit 1
}
set node [lindex $argv 0]
set DB [sql connect]
sql selectdb $DB tbdb
if {[catch "exec ssh -n -l root 155.99.214.1$node cat /etc/ssh/ssh_host_key | $sdir/key7" hostkey]} {
puts stderr "ERROR: Could not get hostkey ($hostkey)"
exit 1
}
sql query $DB "select * from ssh_host_keys where node_id=\"tbpc$node\""
if {[sql fetchrow $DB] == ""} {
sql exec $DB "insert into ssh_host_keys values (\"tbpc$node\", '$hostkey')"
} else {
sql exec $DB "update ssh_host_keys set ssh_key='$hostkey' where node_id=\"tbpc$node\""
}
#!/usr/local/bin/tclsh
set sdir [file dirname [info script]]
if {[file dirname [info script]] == "."} {
load ../lib/sql.so
} else {
load [file dirname [file dirname [info script]]]/lib/sql.so
}
if {[llength $argv] != 1} {
puts stderr "Syntax: $argv0 <node#>"
exit 1
}
set node [lindex $argv 0]
set DB [sql connect]
sql selectdb $DB tbdb
sql query $DB "select * from ssh_host_keys where node_id=\"tbpc$node\""
set key [sql fetchrow $DB]
if {$key != ""} {
puts [exec echo [lindex $key 1] | $sdir/key8]
}
#include <stdio.h>
int main()
{
char buf[1024*32];
int size;
int i;
size = fread(buf,1,1024*32,stdin);
for (i=0;i<size;++i) {
printf("%02x",buf[i]);
}
fflush(stdout);
return 0;
}
#include <stdio.h>
#define TONUM(x) (x >= '0' && x <= '9' ? x - '0' : 10 + (x - 'a'))
int main()
{
char buf[1024*32];
int size;
int i;
size = fread(buf,1,1024*32,stdin);
for (i=0;i<size;i+=2) {
printf("%c",TONUM(buf[i])*16+TONUM(buf[i+1]));
}
fflush(stdout);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment