]>
Commit | Line | Data |
---|---|---|
e78de92e MT |
1 | #!/bin/bash |
2 | ||
3 | # Create the host keys for the OpenSSH server. | |
4 | # | |
5 | ||
6 | # Some functions to make the below more readable | |
7 | KEYGEN=/usr/bin/ssh-keygen | |
8 | RSA1_KEY=/etc/ssh/ssh_host_key | |
9 | RSA_KEY=/etc/ssh/ssh_host_rsa_key | |
10 | DSA_KEY=/etc/ssh/ssh_host_dsa_key | |
11 | ||
12 | do_rsa1_keygen() { | |
13 | if [ ! -s $RSA1_KEY ]; then | |
14 | rm -f $RSA1_KEY | |
15 | if test ! -f $RSA1_KEY && $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then | |
16 | chgrp ssh_keys $RSA1_KEY | |
17 | chmod 600 $RSA1_KEY | |
18 | chmod 644 $RSA1_KEY.pub | |
19 | if [ -x /sbin/restorecon ]; then | |
20 | /sbin/restorecon $RSA1_KEY.pub | |
21 | fi | |
22 | else | |
23 | exit 1 | |
24 | fi | |
25 | fi | |
26 | } | |
27 | ||
28 | do_rsa_keygen() { | |
29 | if [ ! -s $RSA_KEY ]; then | |
30 | rm -f $RSA_KEY | |
31 | if test ! -f $RSA_KEY && $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then | |
32 | chgrp ssh_keys $RSA_KEY | |
33 | chmod 600 $RSA_KEY | |
34 | chmod 644 $RSA_KEY.pub | |
35 | if [ -x /sbin/restorecon ]; then | |
36 | /sbin/restorecon $RSA_KEY.pub | |
37 | fi | |
38 | else | |
39 | exit 1 | |
40 | fi | |
41 | fi | |
42 | } | |
43 | ||
44 | do_dsa_keygen() { | |
45 | if [ ! -s $DSA_KEY ]; then | |
46 | rm -f $DSA_KEY | |
47 | if test ! -f $DSA_KEY && $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then | |
48 | chgrp ssh_keys $DSA_KEY | |
49 | chmod 600 $DSA_KEY | |
50 | chmod 644 $DSA_KEY.pub | |
51 | if [ -x /sbin/restorecon ]; then | |
52 | /sbin/restorecon $DSA_KEY.pub | |
53 | fi | |
54 | else | |
55 | exit 1 | |
56 | fi | |
57 | fi | |
58 | } | |
59 | ||
60 | # Create keys | |
61 | do_rsa_keygen | |
62 | do_rsa1_keygen | |
63 | do_dsa_keygen |