Browse code

Adding SSHFP generator

Veselin Kolev authored on 29/12/2019 02:39:10
Showing 3 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,21 @@
1
+#!/usr/bin/env sh
2
+# A secure way to create SSHFP records (local) | Danny Fullerton - mantor.org | license: public domain
3
+# Modified by Veselin Kolev <vlk@lcpe.uni-sofia.bg> - 20191229
4
+if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
5
+  printf "Usage:\t$0 <hostname>\n\t$0 host.uni-sofia.bg.\n" >&2
6
+  exit 1
7
+fi
8
+name=$1
9
+cipher1='rsa'; cipher2='dsa'; cipher3='ecdsa'; cipher4='ed25519'
10
+hash2='sha256'
11
+for i in 3 4; do # cipher
12
+  for j in 2; do # hash
13
+    eval "key_path=/etc/ssh/ssh_host_\${cipher${i}}_key.pub"
14
+    if [ -f $key_path ]; then
15
+      eval "h=\${hash${j}}"
16
+      sshfp=`awk '{print $2}' $key_path | openssl base64 -d -A | openssl dgst -${h} | sed 's/^.* //' | awk '{print $1}' | tr '[a-z]' '[A-Z]'`
17
+      printf "${name} IN SSHFP ${i} ${j} ${sshfp}\n"
18
+    fi
19
+  done
20
+done
21
+
0 22
new file mode 100755
... ...
@@ -0,0 +1,21 @@
1
+#!/usr/bin/env sh
2
+# A secure way to create SSHFP records (local) | Danny Fullerton - mantor.org | license: public domain
3
+# Modified by Veselin Kolev <vlk@lcpe.uni-sofia.bg> - 20191229
4
+if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
5
+  printf "Usage:\t$0 <hostname>\n\t$0 host.uni-sofia.bg.\n" >&2
6
+  exit 1
7
+fi
8
+name=$1
9
+cipher1='rsa'; cipher2='dsa'; cipher3='ecdsa'; cipher4='ed25519'
10
+hash2='sha256'
11
+for i in 1 3 4; do # cipher
12
+  for j in 2; do # hash
13
+    eval "key_path=/etc/ssh/ssh_host_\${cipher${i}}_key.pub"
14
+    if [ -f $key_path ]; then
15
+      eval "h=\${hash${j}}"
16
+      sshfp=`awk '{print $2}' $key_path | openssl base64 -d -A | openssl dgst -${h} | sed 's/^.* //' | awk '{print $1}' | tr '[a-z]' '[A-Z]'`
17
+      printf "${name} IN SSHFP ${i} ${j} ${sshfp}\n"
18
+    fi
19
+  done
20
+done
21
+
0 22
new file mode 100755
... ...
@@ -0,0 +1,21 @@
1
+#!/usr/bin/env sh
2
+# A secure way to create SSHFP records (local) | Danny Fullerton - mantor.org | license: public domain
3
+# Modified by Veselin Kolev <vlk@lcpe.uni-sofia.bg> - 20191229
4
+if [ $# -ne 1 ] || [ "$1" = "-h" ]; then
5
+  printf "Usage:\t$0 <hostname>\n\t$0 host.uni-sofia.bg.\n" >&2
6
+  exit 1
7
+fi
8
+name=$1
9
+cipher1='rsa'; cipher2='dsa'; cipher3='ecdsa'; cipher4='ed25519'
10
+hash2='sha256'
11
+for i in 1 2 3 4; do # cipher
12
+  for j in 2; do # hash
13
+    eval "key_path=/etc/ssh/ssh_host_\${cipher${i}}_key.pub"
14
+    if [ -f $key_path ]; then
15
+      eval "h=\${hash${j}}"
16
+      sshfp=`awk '{print $2}' $key_path | openssl base64 -d -A | openssl dgst -${h} | sed 's/^.* //' | awk '{print $1}' | tr '[a-z]' '[A-Z]'`
17
+      printf "${name} IN SSHFP ${i} ${j} ${sshfp}\n"
18
+    fi
19
+  done
20
+done
21
+