Statistics
| Branch: | Revision:

root / example / hooks / linux / ssh @ 8d77389f

History | View | Annotate | Download (1.5 kB)

1 60484bb3 Lance Albertson
#!/bin/bash
2 60484bb3 Lance Albertson
3 f1afb4b1 Lance Albertson
# Copyright (C) 2010 Oregon State University
4 f1afb4b1 Lance Albertson
#
5 f1afb4b1 Lance Albertson
# This program is free software; you can redistribute it and/or modify
6 f1afb4b1 Lance Albertson
# it under the terms of the GNU General Public License as published by
7 f1afb4b1 Lance Albertson
# the Free Software Foundation; either version 2 of the License, or
8 f1afb4b1 Lance Albertson
# (at your option) any later version.
9 f1afb4b1 Lance Albertson
#
10 f1afb4b1 Lance Albertson
# This program is distributed in the hope that it will be useful, but
11 f1afb4b1 Lance Albertson
# WITHOUT ANY WARRANTY; without even the implied warranty of
12 f1afb4b1 Lance Albertson
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 f1afb4b1 Lance Albertson
# General Public License for more details.
14 f1afb4b1 Lance Albertson
#
15 f1afb4b1 Lance Albertson
# You should have received a copy of the GNU General Public License
16 f1afb4b1 Lance Albertson
# along with this program; if not, write to the Free Software
17 f1afb4b1 Lance Albertson
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 f1afb4b1 Lance Albertson
# 02110-1301, USA.
19 f1afb4b1 Lance Albertson
#
20 60484bb3 Lance Albertson
# Remove all generated keys so that each instance has unique keys for ssh
21 60484bb3 Lance Albertson
22 c6253116 Lance Albertson
set -e
23 c6253116 Lance Albertson
24 60484bb3 Lance Albertson
. common.sh
25 60484bb3 Lance Albertson
26 e7a2d1ad Lance Albertson
debug set -x
27 e84e87cd Lance Albertson
28 60484bb3 Lance Albertson
HOST_KEY="/etc/ssh/ssh_host_key"
29 60484bb3 Lance Albertson
RSA_KEY="/etc/ssh/ssh_host_rsa_key"
30 60484bb3 Lance Albertson
DSA_KEY="/etc/ssh/ssh_host_dsa_key"
31 60484bb3 Lance Albertson
32 83edc99e Lance Albertson
if [ -e ${TARGET}/etc/debian_version ] ; then
33 83edc99e Lance Albertson
    echo "Debian/Ubuntu: replace existing ssh keys"
34 d9679ad7 Lance Albertson
    [ -f "${TARGET}/${RSA_KEY}" ] && rm -f ${TARGET}/${RSA_KEY}* && \
35 83edc99e Lance Albertson
        ssh-keygen -t rsa -q -N '' -f ${TARGET}/${RSA_KEY}
36 241fb6e1 Lance Albertson
    [ -f "${TARGET}/${DSA_KEY}" ] && rm -f ${TARGET}/${DSA_KEY}* && \
37 83edc99e Lance Albertson
        ssh-keygen -t dsa -q -N '' -f ${TARGET}/${DSA_KEY}
38 83edc99e Lance Albertson
    exit 0
39 83edc99e Lance Albertson
fi
40 83edc99e Lance Albertson
41 60484bb3 Lance Albertson
for key in $HOST_KEY $RSA_KEY $DSA_KEY ; do
42 60484bb3 Lance Albertson
    if [ -f "${TARGET}/${key}" ] ; then
43 241fb6e1 Lance Albertson
        rm -f ${TARGET}/${key}*
44 60484bb3 Lance Albertson
    fi
45 60484bb3 Lance Albertson
done
46 60484bb3 Lance Albertson
47 60484bb3 Lance Albertson
exit 0