summaryrefslogtreecommitdiff
path: root/src/publish-ip.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2017-03-25 15:20:01 -0400
committerAndrew Cady <d@jerkface.net>2017-03-25 15:20:01 -0400
commit492c1ac5030d0826afc1d69ff3b2ec9ffa0345f2 (patch)
tree1a224b6057e5506bb905697e56fa993088e1a16a /src/publish-ip.sh
parent20af6a738d3d5ca1889c530dcdc2180eb32dc8ff (diff)
publish-ip script will work on systems without kiki
Instead of just looking for host keys where kiki leaves them, publish-ip will (after not finding kiki keys) try to access the system keys, and even use the user's keys. Thus it is now appropriate to run stand-alone on any Debian machine.
Diffstat (limited to 'src/publish-ip.sh')
-rwxr-xr-xsrc/publish-ip.sh21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/publish-ip.sh b/src/publish-ip.sh
index 7da41b9..37fd2e3 100755
--- a/src/publish-ip.sh
+++ b/src/publish-ip.sh
@@ -1,5 +1,8 @@
1#!/bin/sh 1#!/bin/sh
2 2
3kiki_hostkey=/var/cache/kiki/config/ssh_host_rsa_key
4debian_hostkey=/etc/ssh/ssh_host_rsa_key
5
3determine_lan_ip() 6determine_lan_ip()
4{ 7{
5 ip -4 -oneline addr show | 8 ip -4 -oneline addr show |
@@ -8,8 +11,13 @@ determine_lan_ip()
8 *'scope global'*) ;; 11 *'scope global'*) ;;
9 *) continue ;; 12 *) continue ;;
10 esac 13 esac
11 case "$ip" in 14 # Exclude our IP address on br0 -- hosts connected via this device should
12 192.168.10.1/24) continue ;; 15 # be receiving DNS servers from us via DHCP, so dyndns is unnecessary.
16 # However, perhaps we could install a third entry in the dyndns. (Perhaps
17 # something like *.br0.ssh.cryptonomic.net would give us automatic names
18 # for all devices.)
19 case "$dev" in
20 br0) continue ;;
13 esac 21 esac
14 echo ${ip%/*} 22 echo ${ip%/*}
15 break 23 break
@@ -35,4 +43,11 @@ else
35 set -- 43 set --
36fi 44fi
37 45
38ssh -o GlobalKnownHostsFile="$tmpfile" -i /var/cache/kiki/config/ssh_host_rsa_key dyndns@ssh.cryptonomic.net "$@" 46hostkey=
47for f in "$kiki_hostkey" "$debian_hostkey"; do
48 [ -r "$f" ] || continue
49 hostkey=$f
50 break
51done
52
53ssh -o GlobalKnownHostsFile="$tmpfile" ${hostkey:+ -i "$hostkey"} dyndns@ssh.cryptonomic.net "$@"