Skip to content

Latest commit

 

History

History
168 lines (129 loc) · 4.86 KB

synology.adoc

File metadata and controls

168 lines (129 loc) · 4.86 KB

Synology Synology

ssh

enable service

To enable SSH access, go on DSM web interface : - activate SSH in panel config > terminal & SNMP, - change default port (one of most important point to secure your NAS),

connect through SSH as root (the only user allowed on SSH): - edit /etc/passwd (eg. vi /etc/passwd), - for the user you want, change the end of line /sbin/nologin with /bin/ash, - save, quit and loggoff (^D).

to check : - reconnect through SSH as user.

ssh key

As user, do:

Make sure you have home directory.

create ssh key :

$> ssh-keygen -t dsa

Make sure home dir permission is 755 (cf: [superuser][su]) :

$> cd
$> chmod 755 ~/
$> chmod 700 ~/.ssh
$> chmod 600 ~/.ssh/authorized_keys

Then, copy public key on remote server

$> scp -P PORT .ssh/id_dsa.pub USER@REMOTE:.ssh/authorized_keys
Warning
this will erase previously key set

replace:

  • PORT: by the port number you selected when you activated SSH (default is 23, but strongly recommend to change this),

  • USER: the user name on the remote server,

  • REMOTE : domain name (or ip) of the remote server.

SU

Git server

why ? Enable git server package in DSM, and allow port forwarding in ssh. Edit /etc/ssh/ssh_config

uncomment the following line :

AllowForwarding yes

opkg packet manager

install

$> sudo su
$> mkdir -p /volume1/@entware-ng/opt
# Remove /opt and create a symlink
$> rm -rf /opt
$> ln -sf /volume1/@entware-ng/opt /opt
# launch install script
$> wget -O - http://pkg.entware.net/binaries/armv7/installer/entware_install.sh | /bin/sh
# update
$> /opt/bin/opkg update
$> /opt/bin/opkg upgrade
$> /opt/bin/opkg install nano

To add /opt to $PATH : add the following line in the end of /root/.profile and /etc/profile file

/root/.profile
. /opt/etc/profile
Note
As of DSM 6.0, /etc/rc.local is no longer executed as part of the boot process.

crontab

Note
/etc/crontab is reset at each synology updates. I recommend to use the synology cron handler (in DSM) instead of directly edit crontab by your own.

rsync

To clone a directory

$> rsync `# do not use -a avoid perms/owner preservation` \
        --rsh 'ssh -p 22'       `# Specify ssh options to use` \
        --rsync-path=PATH       `# Specify path of rsync on remote` \
        --verbose  \
        --progress              `# monitor the progress of data or data transfer.`\
        --recursive \
        --compress              `# Compress file data during the transfer` \
        --partial               `# Keep partially transferred files` \
        --partial-dir=DIR       `# put a partially transferred file into DIR` \
        --links                 `# Copy symlinks as symlinks` \
        --times                 `# preserve modification times (important for update)` \
        --update                `# Skip files that are newer on the receiver` \
        --checksum              `# replace the times+sizes heuristic with sizes+md5 one` \
        --delete                `# Delete extraneous files from destination dirs` \
        --exclude '@eaDir'      `# exclude syno junk files` \
        --exclude 'Thumbs.db'   `# windows syno junk metadata` \
        /sourceDir/ HOSTNAME:/destDir/

Making versioned archive

...
        --backup   `# make a backup of what changed on destination` \
        --backup-dir=/destDir/$( date +"%Y-%m-%d-%H-%M" )/  `#` \
...

--itemize-change and the --dry-run options to figure out how the command will behave before launching the real one.

...
        --itemize-changes       `# output a change-summary for all updates` \
        --dry-run               `# perform a trial run with no changes made` \
...

see more rsync.adoc

git

Installing git package using opkg (see above) is not complete. If you encounter the following error, you might install additional `git-http`package.

missing git-http
git: 'remote-https' is not a git command. See 'git --help
install git-http
$> sudo opkg install git git-http wget-ssl