silent update
[ssh-dyndns.git] / README.rst
index 002b0116e556e92a36c949b200bfbcef171bdd0d..34f507ccc07d3b5d7f1d0d8f427a9ab990e5cdf7 100644 (file)
@@ -10,6 +10,7 @@ SSH provides secure, password-less key-based authentication.
 
 Upon login, the remote IP is used to create/update a tinydns file with the
 DNS record for a hostname given by the SSH client.
+In addition to the IP record, a TXT record with the update time will be added.
 
 tinydns is part of the dbjdns/dbndns package.
 
@@ -18,6 +19,8 @@ tinydns is part of the dbjdns/dbndns package.
 Setup
 =====
 
+Server
+======
 1. Clone ssh-dyndns into a sensible location, e.g. ``/usr/local/src/ssh-dyndns``::
 
     $ cd /usr/local/src/ && git clone git://git.cweiske.de/ssh-dyndns.git
@@ -26,11 +29,10 @@ Setup
 
     $ useradd -g nogroup -m -N -s /usr/local/src/ssh-dyndns/ssh-dyndns dyndns
 
-3. Setup password-less ssh keys for the dyndns user::
+3. Prepare password-less ssh keys for the dyndns user::
 
     $ su - dyndns -s /bin/bash
     $ mkdir ~/.ssh
-    $ cat /path/to/key.pub >> ~/.ssh/authorized_keys
 
 4. Prevent showing login messages::
 
@@ -49,6 +51,29 @@ Setup
     dyndns  ALL= NOPASSWD: /usr/bin/make
 
 
+Client
+======
+On a machine at home, or which other IP you want to dyndns, setup a new ssh key
+as one of your users::
+
+    $ mkdir ~ssh-dyndns
+    $ cd ~/ssh-dyndns
+    $ ssh-keygen -N "" -C "dyndns@home.example.org" -f ~/ssh-dyndns/ssh-dyndns_rsa
+
+Copy the contents of the public key (``ssh-dyndns_rsa.pub``) into
+``/home/dyndns/.ssh/authorized_keys`` on your server.
+
+Run the next command manually to confirm the new ssh key::
+
+    $ cd ~/ssh-dyndns/ && ssh -i ssh-dyndns_rsa dyndns@example.org home.example.org
+
+If that worked, and you DNS entry worked, add the command to cron::
+
+    $ crontab -e
+    # update dns entry home.example.org every 5 minutes
+    */5 * * * *  cd /home/$user/ssh-dyndns/ && ssh -i ssh-dyndns_rsa dyndns@example.org home.example.org
+
+
 Configuration
 =============
 The configuration file template ``ssh-dyndns.sh.config-dist`` may be copied
@@ -92,6 +117,35 @@ compile the ``data.cdb`` file.
 tinydns will automatically pick up the change.
 
 
+Check time of last update
+=========================
+::
+
+    $ dig +short home.example.org ANY
+    "Last update 2013-08-21 21.21.28+02.00."
+    123.45.67.89
+
+
+Test
+====
+You can test it locally:
+
+1. Create config file::
+
+     $ cp ssh-dyndns.sh.config-dist ~/.config/ssh-dyndns.sh
+
+2. Create dummy makefile::
+
+     $ touch /tmp/Makefile
+
+3. Run it::
+
+     $ SSH_CLIENT=192.168.1.4 SSH_CONNECTION=1 ./ssh-dyndns foo home.example.org
+
+4. See generated file::
+
+     $ cat /tmp/data-dyndns-home.example.org
+
 ====
 Bugs
 ====