Andreashej
Andreashej

Reputation: 11

SSH from Synology NAS to remote server

When I run competitions for Icelandic Horses, I want to automatically upload the results from our Synology NAS to a remote webserver. The program we use automatically generates the html-files that needs to be uploaded.

What is the easiest way to achieve this? I have SSH access on both the NAS and the webserver.

Any help is appreciated :)

Upvotes: 1

Views: 2285

Answers (1)

Manolo Pirolo
Manolo Pirolo

Reputation: 656

In this case you can create a cron task in the synology console with the command:

sudo -i
vi /etc/crontab

Edit the file and add a line like this at the end of the file with a scp command:

0 0 * * * root scp -r "-i/root/.ssh/mykey" '[email protected]:/some/remote/path' '/some/local/path'

Finally you have to reload the configuration restarting the service with:

synoservice -restart crond

Before all this you must to configure a pair keys to avoid the password entry:

  • cd to a private directory of the user which will be running the script (typically "$HOME/.ssh", to be created if needed). That directory must be protected to write acces from other users, fix the modes if needed.
  • generate the keypair using command "ssh-keygen" ("/usr/syno/bin/ssh-keygen" if not in your PATH)
  • at the prompt "Enter file in which to save the key", choose a file name (let's say "mykey")
  • at the prompt "Enter passphrase (empty for no passphrase):" press return (this will create a passwordless private key)
  • Two files will be created: "mykey" and "mykey.pub"
  • copy the contents of mykey.pub inside "$HOME/.ssh/authorized_key" file of user account on the remote machine your script is going to connect to.
  • in your script, add "-i" as argument to the ssh command

Also in this forum is explained how to make the copy with rsync instead of scp

Upvotes: 1

Related Questions