]>
Commit | Line | Data |
---|---|---|
e78de92e | 1 | #!/bin/bash |
ba1319f4 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2015 Michael Tremer # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
e78de92e | 21 | |
ba1319f4 | 22 | ALGOS="rsa ecdsa ed25519" |
e78de92e | 23 | |
ba1319f4 MT |
24 | main() { |
25 | local ret=0 | |
e78de92e | 26 | |
ba1319f4 MT |
27 | local algo |
28 | for algo in ${ALGOS}; do | |
29 | local keyfile="/etc/ssh/ssh_host_${algo}_key" | |
30 | ||
31 | # If the key already exists, there is nothing to do | |
32 | [ -e "${keyfile}" ] && continue | |
33 | ||
34 | # Generate a new key | |
35 | if ! ssh-keygen -qf "${keyfile}" -N '' -t "${algo}"; then | |
36 | ret=1 | |
37 | continue | |
e78de92e | 38 | fi |
ba1319f4 MT |
39 | |
40 | # Fix permissions | |
41 | chgrp ssh_keys "${keyfile}" | |
42 | chmod 600 "${keyfile}" | |
43 | chmod 644 "${keyfile}.pub" | |
44 | done | |
45 | ||
46 | return ${ret} | |
e78de92e MT |
47 | } |
48 | ||
ba1319f4 | 49 | main; exit $? |