Rsync error

377 views
Skip to first unread message

Jens-Jørgen Kjærgaard

unread,
Sep 1, 2018, 7:10:08 AM9/1/18
to weewx-user
For some years, I have been running weewx with no major problems, on a raspberry.

Now I want to upload to an extra server (also raspberry), using rsync.
However, I get

rsyncupload: [['rsync', '--archive', '--stats', '--delete', '-e ssh', '/home/jjk/weewx/public_html/', 'j...@185.127.50.88:/media/hytte']] reported errors: Permission denied, please try again.. Permission denied (publickey,password).. rsync: connection unexpectedly closed (0 bytes received so far) [sender]. rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]

I understand there is a problem with my publickey or password.
However, when I from the same raspberry use sftp or ssh or even try rsync with the same settings, I have no problem uploading the files - it is only when I try using weewx, I get the problem. Of course I can upload the files with sftp - but it would be more elegant from inside weewx.

The relevant Rsync section of weewx.conf:

[[RSYNC]]
        # rsync'ing to a webserver is treated as just another report
        skin = Rsync
        
        # If you wish to use rsync, you must configure passwordless ssh using
        # public/private key authentication from the user account that weewx
        # runs as to the user on the remote machine where the files
        # will be copied.
        #
        # The following three lines determine where files will be sent.
        server = 185.127.50.88
        path = /media/hytte
        user = jjk
        
        # Rsync can be configured to remove files from the remote server if
        # they don't exist under HTML_ROOT locally. USE WITH CAUTION: if you
        # make a mistake in the remote path, you could could unintentionally
        # cause unrelated files to be deleted. Set to 1 to enable remote file
        # deletion, zero to allow files to accumulate remotely.
        delete = 1

?

Thomas Keffer

unread,
Sep 1, 2018, 7:55:23 AM9/1/18
to weewx-user
If you can use rsync just fine from the command line, but not from within WeeWX, the problem may be the user you are using to run WeeWX. Is it the same? Or, is it root? Or, something else?

-tk

--
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 weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jens-Jørgen Kjærgaard

unread,
Sep 1, 2018, 8:23:46 AM9/1/18
to weewx-user
I'm running weewx as root.
I didn't think it had influence on the private keys - but obviously it has.
So I have to create another key as root - or run weewx as my username?

Jens-Jørgen Kjærgaard
Tuenvej 818
9870 Sindal


You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/BDeqPnam8fw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.

mwall

unread,
Sep 1, 2018, 9:13:31 AM9/1/18
to weewx-user


On Saturday, September 1, 2018 at 8:23:46 AM UTC-4, Jens-Jørgen Kjærgaard wrote:
I'm running weewx as root.
I didn't think it had influence on the private keys - but obviously it has.
So I have to create another key as root - or run weewx as my username?



ssh keys can be used by any user.

if you generated the ssh keys as user 'jens', you should have this:

~jens/.ssh/id_rsa
~jens/.ssh/id_rsa.pub

you just need to tell weewx to use that identity file for rsync connections (by default, if you run rsync as root it will look for /root/.ssh/id_rsa and /root/.ssh/id_rsa.pub)

how does one tell rsync to use a specific certificate?

rsync -e "ssh -i /home/jens/.ssh/id_rsa" ...

but there is no mechanism in weewx to pass those additional arguments.  so use the ssh config file for the user who is running weewx (in this case, that means root):

in the file /root/.ssh/config do this:

  IdentityFile /home/jens/.ssh/id_rsa

so then any time you try to do anything that uses ssh (rsync, scp, ssh) to nameofrsyncserver.com, ssh will use the identity of jens to make the connection.

note that you can also generate ssh keys specifically for the weewx process or a weewx user, then use those to connect to your server.  that would be the safest thing to do, and run weewx as the weewx user.

m

mwall

unread,
Sep 1, 2018, 9:29:22 AM9/1/18
to weewx-user
you should also specify the user in the ssh config file:

  User jens
  IdentityFile /home/jens/.ssh/id_rsa

in the world of ssh, the user is independent of the ssh certificates.  so it is usually a good idea to specify user just to be safe.

for example, you might be 'jens' on the computer on which weewx is running, but jensjorgen on the rsync server.  in that case you would specify 'User jensjorgen' in the ssh config file.

m

Jens-Jørgen Kjærgaard

unread,
Sep 1, 2018, 10:52:53 AM9/1/18
to weewx-user
First I tried to generate a new id_rsa as root, but as you would expect, it changed nothing.
Next, I did as you suggested, and now it works - thanks.

Though I don't quite know why :).

But in the /etc/root/.ssh/config file (not /root/.ssh/config) by default, 

Hosts *

- I would guess that the * means any ip?
However, replacing it with my server ip solved the problem anyway.
So, everything is fine now - I will try, someday, to not use root as user, I know I shouldn't - but it is a bit hard to change a working system :)

Thanks for helping out.

Jens-Jørgen Kjærgaard
Tuenvej 818
9870 Sindal

--

Maginos

unread,
Nov 6, 2018, 5:12:34 PM11/6/18
to weewx-user
Thank you mwall for your tip, it helped me too. For your information, the path of the ssh_config file was for me /etc/ssh/ssh_config.

Best regards and thank you again!
Maginos
Reply all
Reply to author
Forward
0 new messages