Reputation: 345
I'm following this project that basically is a tutorial to create a local webpage and display the room temperature and humidity when you are in the local network and you access to it by going to the ip adress of the pi, there must be an apache/nginx server running.
What i want to do is use a remote webserver that i have (it's a VPS actually, so i have ssh access) for it to be acessible from anywhere, so instead of having the html and javascript and css on the pi, i'll have those on the remote server, but the pi will keep track of the temperature and create the logs, how can i send these logs every minute to the remote webserver?
Also, later, if i want to include a switch on the website to control whatever on the pi, how could i run a script on the pi, via ssh, via html frontend? (javascript? triggers ssh command to the pi and that triggers the gpio according to the script)
Thanks,
Upvotes: 0
Views: 277
Reputation: 12785
Most unix systems come with rsync, a remote and local file synchronization tool, installed and you can setup a cron job to run it and send the log file to the VPS at specified intervals.
So on your PI, you should be able to run
rsync -az /PI/path/to/log.file [email protected]:/VPS/path/to/log.file
Now, this would require a password each time it is run which would prevent automatic updates but you can use SSH authentication keys. This is a good guide on setting up SSH auth keys. Go from the part titled "SSH Keygen" to "SSH Permissions".
Upvotes: 1
Reputation: 9893
As much as I've understood, your looking for a way to transfer data from raspi
to your VPS
by means of ssh
.
Well one options is to use scp
- secure copy, scp
copies files between hosts on a network. It uses ssh
for data transfer, and uses the same authentication and provides the same security as ssh
Another option is to mount your remote file system by means of sshfs
- (Secure SHell FileSystem) is a file system for Linux capable of operating on files on a remote computer using just a secure shell login on the remote computer.
P.S. Honestly speaking the data transfers by means of ssh
is not an elegant solution in your case.
Upvotes: 0