8

Now I mount an encrypted folder:

  1. open browser and login to NAS gui
  2. click Control panel -> Shared Folder > Encryption > Mount
  3. enter key
  4. after folder is mounted:

    rsync -ah --progress --delete /path/* admin@ipadress:/volume1/path/
    

Can I bypass 1.-3. and use ssh only?

  • You're asking if you can run one ssh command that opens a browser, logs in to the NAS, clicks in specific places, enters a key, then runs an rsync command? – Jeff Schaller Jul 15 '16 at 22:16
  • 1
    I can connect to NAS with ssh, therefore bypassing the gui altogether. If I can do this with ssh, I can automatize this process. – Ohto Nordberg Jul 16 '16 at 8:33
  • Does the key change every time? – Jeff Schaller Jul 16 '16 at 12:32
  • No. The key is in an encrypted file, which I first open, then paste to NAS gui. – Ohto Nordberg Jul 16 '16 at 14:23
  • Does the "ssh" process need to open this encrypted file, or else how will the key be transmitted? – Jeff Schaller Jul 16 '16 at 14:44
6

Use the gui to mount the encrypted directory, then login to the synology as root over ssh and type mount. You will see a line like

 /volume1/@mycryptdir@ on /volume1/mycryptdir type ecryptfs (rw,relatime,ecryptfs_fnek_sig=88...,ecryptfs_sig=88...,ecryptfs_cipher=aes,ecryptfs_key_bytes=32)

This shows your directory /volume1/mycryptdir is implemented on an underlying /volume1/@mycryptdir@ directory using ecryptfs. Unmount the directory with the gui, then try the following command:

# ecryptfs-add-passphrase
Passphrase: 

Type in the cleartext passphrase you originally used (not the .key file). It will reply

Inserted auth tok with sig [88...] into the user session keyring

Now type the mount command using the options you saw before. You will need to create the mount point directory:

# mkdir /volume1/mycryptdir
# mount /volume1/\@mycryptdir\@/  /volume1/mycryptdir/ -t ecryptfs -o rw,relatime,ecryptfs_fnek_sig=88...,ecryptfs_sig=88...,ecryptfs_cipher=aes,ecryptfs_key_bytes=32

Your filesystem should now be mounted and useable. You should now clear the password from the in-memory keyring:

# keyctl clear @u

When you have finished, unmount the directory with umount /volume1/mycryptdir.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.