diff options
author | Andrew Cady <d@jerkface.net> | 2017-03-25 15:20:01 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2017-03-25 15:20:01 -0400 |
commit | 492c1ac5030d0826afc1d69ff3b2ec9ffa0345f2 (patch) | |
tree | 1a224b6057e5506bb905697e56fa993088e1a16a /src | |
parent | 20af6a738d3d5ca1889c530dcdc2180eb32dc8ff (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')
-rwxr-xr-x | src/publish-ip.sh | 21 |
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 | ||
3 | kiki_hostkey=/var/cache/kiki/config/ssh_host_rsa_key | ||
4 | debian_hostkey=/etc/ssh/ssh_host_rsa_key | ||
5 | |||
3 | determine_lan_ip() | 6 | determine_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 -- |
36 | fi | 44 | fi |
37 | 45 | ||
38 | ssh -o GlobalKnownHostsFile="$tmpfile" -i /var/cache/kiki/config/ssh_host_rsa_key dyndns@ssh.cryptonomic.net "$@" | 46 | hostkey= |
47 | for f in "$kiki_hostkey" "$debian_hostkey"; do | ||
48 | [ -r "$f" ] || continue | ||
49 | hostkey=$f | ||
50 | break | ||
51 | done | ||
52 | |||
53 | ssh -o GlobalKnownHostsFile="$tmpfile" ${hostkey:+ -i "$hostkey"} dyndns@ssh.cryptonomic.net "$@" | ||