I recently setup rsync with weewx. This took a couple of hours, and help
from my friends, so I wrote out all the steps I used to make it work.
This is not the only way to make rsync work, but a single set of
instructions.
Liz
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/f110b3eb-56e2-4909-8d11-3940a4d3f7ben%40googlegroups.com.
1. Work out
which computer is the source (the one collecting the weather data)
which computer is the destination (the one where the public to check
your weather site)
on the destination computer, what is the user name for the webserver
the IP address of the destination computer eg 192.168.1.1 OR its domain
name eg myweather.com
the correct paths for the data on each computer
and, on your source computer which is your weewx.conf file
2. Install any packages required - ssh, rsync
Check that ssh on the destination will accept key pair login
Make sure you have ssh access to both computers
3. On the source computer make a new private / public key pair.
Don't overwrite an existing pair.
From your user directory check for previous existing pairs
$ ls -al ~/.ssh/id_*.pub
If you get "No such file or directory" you are set to go. If you have
existing key pairs you need
to either move them out of the way temporarily or risk reusing them.
To make the new key pair
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
The email address is not critical, but it helps you identify the key.
You might have
'[email protected]'
Accept the default file location for your key pair, and just press
enter for the passphrase, twice.
Check that you now have two files
$ ls ~/.ssh/id_*
output /home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub
id_rsa is your private key, to stay on your source computer
id_rsa.pub is your public key to put on the destination computer.
4. Copy the Public key to its new home
Firstly copy the public key to your directory on the destination.
$ ssh-copy-id your_destination_username@destination_server_ip_address
(eg [email protected])
You should find in /home/user/.ssh/authorized_keys the identical file
to id_rsa.pub
Before you move it again, check you can do a passwordless login via ssh
from your source computer
$ ssh [email protected] or ssh [email protected] (use the correct
address)
If this doesn't work you need to check your ssh configurations
Once you can do the passwordless login, move the file.
Here you need the user name for the webserver. On Debian its www-data.
Move with sudo, then change the ownership of the file to www-data
$ sudo mv .ssh/authorized_keys ~www-data/.ssh/authorized keys
$ sudo chown www-data:www-data ~www-data/.ssh/authorized_keys
British English users need to resist the temptation to change the
spelling.
Test again from your source computer
$ ssh [email protected] or ssh [email protected] (use the
correct address)
As www-data hasn't got a shell (like bash) you won't be able to do much
without providing one
On the destination computer
$ sudo chsh www-data will allow you to provide a shell eg '/bin/bash'
for www-data
I don't know if this is required.
5. Copy the private key to its new home
Weewx runs as root, so root has to be able to find the private key.
On source computer
$ sudo mv /home/user/.ssh/id_rsa /root/.ssh/id_rsa
6. Test rsync on the command line
$ sudo rsync -arP /var/www/html/weewx/
[email protected]:/var/www/html/weewx/ (use the correct address and paths)
If you get errors check that your webserver user does own the files and
directories on the destination
$ sudo chown -R www-data: /var/www/html/weewx
7. Rsync from weewx every reporting cycle
Edit /etc/weewx/weewx.conf (it may have another path)
Under [[RSYNC]]
remove the hash from the server, path and user lines and put in your
destination server, the path on
the destination server and the username, as in the example here
server = 192.168.1.1
path = /var/www/html/weewx/
user = www-data
Check your work, save the file and restart weewx
8. If its all working, tidy up. Remove the copy of the public key from our home
directory.
$ rm .ssh/id_rsa*
If you moved a key pair from your own user space you need to be put it
back.