summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/publish-ip.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/publish-ip.sh b/src/publish-ip.sh
new file mode 100644
index 0000000..7da41b9
--- /dev/null
+++ b/src/publish-ip.sh
@@ -0,0 +1,38 @@
1#!/bin/sh
2
3determine_lan_ip()
4{
5 ip -4 -oneline addr show |
6 while read n dev _ ip rest; do
7 case "$rest" in
8 *'scope global'*) ;;
9 *) continue ;;
10 esac
11 case "$ip" in
12 192.168.10.1/24) continue ;;
13 esac
14 echo ${ip%/*}
15 break
16 done
17}
18
19ssh_cryptonomic_net__known_hosts()
20{
21cat <<'END'
22|1|ORqVRkqd0LO25vHCB0LezHAgwRE=|ih7EYLpvg9jpU86/0Od0N8Ur36c= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHkIETz7wmKd7TZgb3NPeUElZDjZqw2VPd8yDOBTj5UzUBmcgCyE1oCS3Oe1iO9zJWpPtG0QyYa29lKi+vN6pN4=
23END
24}
25
26tmpfile=$(mktemp) || exit 1
27trap 'rm -f "$tmpfile"' EXIT
28ssh_cryptonomic_net__known_hosts > "$tmpfile"
29
30lan_ip=$(determine_lan_ip)
31
32if [ "$lan_ip" ]; then
33 set -- lan "$lan_ip"
34else
35 set --
36fi
37
38ssh -o GlobalKnownHostsFile="$tmpfile" -i /var/cache/kiki/config/ssh_host_rsa_key dyndns@ssh.cryptonomic.net "$@"