Re: [weewx-user] Re: rsync: host key verification failed - problem

2024-02-08 Thread Kalju
Hi Dominic!

Thanks for the tip. Indeed, the user was changed from *root* to *weewx*
That solved the issue
Thanks!

On Thursday, February 8, 2024 at 11:49:48 AM UTC+2 Dominic Reich wrote:

> Kalju  wrote:
>
> >Hi all,
> >
> >Facing same issue with ERROR weeutil.rsyncupload:  Host key 
> verification
> >failed error. 
> >However, it's really strange...
> >I can ssh to remote site as both root as well as pi user
> >I can do manual rsync with no problems but weewx builtin rsync returns 
> above
> >error
> >At the moment my weewx installation is syncing using cron with no 
> problems but
> >I want to understand why builtin rsync fails
> >Problem started after upgrade from weewx 5.0.0 to 5.0.1
> >
> >Any ideas?
>
> Adding the debug info should output the actual rsync command initiated by
> weewx to the logs. That's what I assume when looking at line 104 in
> `src/weeutil/rsyncupload.py` from the sources of 5.0.1.
>
> Maybe that gives a clue in which the actual rsync commands differ and
> why it might fail within Weewx.
>
> Somewhere around 5.0.1 or 5.1.x the user got switched to weewx (not root
> anymore) so maybe there is a problem? (I can't remember when the switch
> was (it was mentioned on the list somwhere) and haven't found it in the
> docs yet)
>
> I'd always suggest looking as what weewx is running so you may not have
> to play the guessing game on which user to look at.
>
> sudo ps ux | grep weewxd
>
> should return the user that actually runs the (python) daemon like on my
> old Raspberry this runs still as root with 4.10.2.
>
> root 690 2.8 1.5 647360 60428 ? Sl Feb06 75:38 python3 
> /usr/share/weewx/weewxd --daemon --pidfile=/var/run/weewx.pid 
> /etc/weewx/weewx.conf
>
> As it was a package-installation I never messed with it, though I
> welcome the change to a non-root package installation per default :)
>
> In case host keys have changed on the server a deletion of the known_hosts
> file within ~/.ssh could also help, probably.
>
> -dominic
>
> >Thank you forward :-)
> >On Friday, July 21, 2023 at 1:14:24 PM UTC+3 Tomasz Lewicki wrote:
> >
> > Thank you for replies.
> >
> > @Warren Gill: yes, I was thinking about crontab but wanted to use 
> built-in
> > solution. Of course crontab is good as backup solution.
> >
> > @vince: you're right, I didn't think about it from this side. Just for
> > record for future seekers:
> >
> > 1. I logged as root ('sudo -i' from 'pi' account)
> > 2. generated SSH keys ('ssh-keygen')
> > 3. copied them to external server ('ssh-copy-id 
> ace...@external.domain.com
> > -p 222')
> > 4. copied /home/pi/.ssh/config to /root/.ssh/config
> > 5. changed owner of 'config' ('chown root:root /root/.ssh/config')
> > 6. waited for next synchronization
> > 7. smiled because everything worked as expected :)
> >
>
> -- 
> Educating the mind without educating the heart is no education at all.
> - Aristotle
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/2c276b90-5b2b-431d-b7ce-16d185f1d672n%40googlegroups.com.


[weewx-user] Re: rsync: host key verification failed - problem

2024-02-08 Thread Kalju
Hi all,

Facing same issue with *ERROR weeutil.rsyncupload:  Host key 
verification failed *error. 
However, it's really strange...
I can ssh to remote site as both *root* as well as *pi* user
I can do manual rsync with no problems but weewx builtin rsync returns 
above error
At the moment my weewx installation is syncing using cron with no problems 
but I want to understand why builtin rsync fails
Problem started after upgrade from weewx 5.0.0 to 5.0.1

Any ideas?
Thank you forward :-)
On Friday, July 21, 2023 at 1:14:24 PM UTC+3 Tomasz Lewicki wrote:

> Thank you for replies.
>
> @Warren Gill: yes, I was thinking about crontab but wanted to use built-in 
> solution. Of course crontab is good as backup solution.
>
> @vince: you're right, I didn't think about it from this side. Just for 
> record for future seekers:
>
> 1. I logged as root ('sudo -i' from 'pi' account)
> 2. generated SSH keys ('ssh-keygen')
> 3. copied them to external server ('ssh-copy-id ace...@external.domain.com 
> -p 222')
> 4. copied /home/pi/.ssh/config to /root/.ssh/config
> 5. changed owner of 'config' ('chown root:root /root/.ssh/config')
> 6. waited for next synchronization
> 7. smiled because everything worked as expected :)
>
> czwartek, 20 lipca 2023 o 23:24:20 UTC+2 vince napisał(a):
>
>> Unless you did something custom, weewx runs as root, not as user 'pi'.
>>
>> You need 'root' to be able to ssh into the remote system with the 
>> user+key you specified.  Same procedure you did to get 'pi' to work, just 
>> do it after sudo(ing) to root so you set the 'root' account up similiarly. 
>>   Two minute thing to do.
>>
>> On Thursday, July 20, 2023 at 1:06:54 PM UTC-7 Tomasz Lewicki wrote:
>>
>>> rsync: host key verification failed
>>>
>>> Dear Weewx users.
>>>
>>> I'm trying to send files generated by Weewx to external webserver (paid 
>>> hosting) with rsync. I'm familiar with rsync, ssh and Linux. Weewx is 
>>> running on Raspberry Pi as 'pi' user. Here are my configs:
>>>
>>> /home/pi/.ssh/config
>>>
>>> Host CF
>>> #HostName external.domain.com <- here of course is real web address
>>> HostName 10.20.30.40 <- here of course is real IP
>>> Port 222
>>> User acetone <- this is my username on remote webserver (hosting)
>>> 
>>> /etc/weewx/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 to the user account on the remote machine where the files
>>> # will be copied.
>>> #
>>> # If you wish to use rsync, set "enable" to "true", then
>>> # fill out server, user, and path.
>>> # The server should appear in your .ssh/config file.
>>> # The user is the username used in the identity file.
>>> # The path is the destination directory, such as 
>>> /var/www/html/weather.
>>> # Be sure that the user has write permissions on the destination!
>>> enable = true
>>> server = external.domain.com
>>> port = 222
>>> user = acetone
>>> path = domains/external.domain.com/private_html/meteo/
>>> 
>>> # To upload files from something other than what HTML_ROOT is set
>>> # to above, specify a different HTML_ROOT here.
>>> #HTML_ROOT = /var/www/html/weewx
>>> 
>>> # 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 = 0
>>>
>>> (...)
>>>
>>> I can log in to external server with ssh (passwordless) with command:
>>>
>>> $ ssh -p 222 ace...@external.domain.com
>>>
>>> or just
>>>
>>> $ ssh CF <- this is host from .ssh/config
>>>
>>> I got error message from weewx:
>>>
>>> Jul 20 21:36:04 WeewxFR24 weewx[28079] DEBUG weeutil.rsyncupload: 
>>> rsyncupload: cmd: [['rsync', '--archive', '--stats', '-e', 'ssh -p 222', 
>>> '/var/www/html/weewx/', 'ace...@external.domain.com:~/domains/
>>> external.domain.com/private_html/meteo']]
>>> Jul 20 21:36:04 WeewxFR24 weewx[28079] ERROR weeutil.rsyncupload: rsync 
>>> reported errors. Original command: ['rsync', '--archive', '--stats', '-e', 
>>> 'ssh -p 222', '/var/www/html/weewx/', 'ace...@external.domain.com:~/domains/
>>> external.domain.com/private_html/meteo']
>>> Jul 20 21:36:04 WeewxFR24 weewx[28079] ERROR weeutil.rsyncupload:  
>>> Host key verification failed.
>>> Jul 20 21:36:04 WeewxFR24 weewx[28079] ERROR weeutil.rsyncupload:  
>>> rsync: connection unexpectedly closed (0 bytes rec