Synology Setup

How to setup your brand new Synology

Synology Setup

posted in productivity on  •   • 

You’ve got yourself a brand new Synology. Now you need ssh, git and Docker so you can actually start using it for more than, you know, mere file storage.

Initial Setup

Getting started is really easy, after connecting your NAS to your local network, navigate to finds.synology.com which figures out the local IP address so you can start the DSM wizard at port 5000.

The DSM (DiskStation Manager) is their handy web UI you can use to configure pretty much everything!

The wizard is pretty self-explanatory from there on out, the only thing you may really want to think about is which RAID you want to be using, for which Synology conveniently offers you their RAID Calculator.

Local IP

Who can remember some random default IP?
Control Panel > Connectivity > Network:

  • Network Interface > LAN 1 > Edit > IPv4 > Use manual configuration
  • General > Server name: Remember that your DSM is also available as “serverName:5000”!

External Access

You will want to access your Synology even when not on your local network. Signing into a Synology Account is a necessary step here:
Control Panel > Services > Synology Account

After that:

  • QuickConnect > Enable QuickConnect: Which sets up an url like QuickConnect.to/serverName
  • DDNS > Add: Keep your dynamic ISP IP in sync with your Synology
    • Service Provider > Synology: Free serverName.synology.me (or other!) domain name.
    • Enable Heartbeat: Get email notifications when your Synology goes down/back up.

Other options

Some other options you may want to tweak right away:

  • Control Panel > System > Notification > Email > Enable email notifications (ex for pwd reset, heartbeat, …)
  • Control Panel > Security > Security > Logout timer (default is 15min)

User Setup

Passwordless Sign-In

Configure passwordless sign-in from the icon at the top right of the DSM and pick “Account” and then either “2-Factor Authentication” or “Passwordless Sign-In”.

Download the Synology Secure SignIn app or use one you already have like Google Authenticator.

Some other interesting options there:

  • Others > Resume DSM to my previous logout status when signed in
  • Display Preferences > Date Format: because MM/dd/YYYY is just plain weird 😉
  • Account > Change Password: Synology will not accept your 44 bits of entropy password
    • Control Panel > User & Group > Advanced > Apply password strength rules

SSH

First, activate your ~/ home:
Control Panel > File Sharing > User & Group > Advanced > User Home > Enable user home service

Then, enable SSH:
Control Panel > Terminal & SNMP > Terminal > Enable SSH Service

If you keep the default port 22 and make it externally available, expect a LOT of login attempt notifications from script kiddies.
You may want to pick a random port instead! Which has it’s own problems.

You may also want to look at Auto Block settings at
Control Panel > Connectivity > Security > Protection

You can now login with your password:

ssh 192.168.1.x -p 22 -luserName

If this fails with error: “unable to start ssh-agent service, error :1058”:

Get-Service -Name ssh-agent | Set-Service -StartupType Manual

Or start in services.msc: OpenSSH Authentication Agent

RSA Key Pairs

Who wants to type that password all the time…

On your Windows (!?) machine:

ssh-keygen

# You could also use DSM to upload the pub file...
cd $env:userprofile/.ssh
scp -P 22 -r ./id_rsa.pub userName@192.168.1.x:~/

On your NAS:

mkdir ~/.ssh
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
rm ~/id_rsa.pub

chmod 755 ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

sudo sed -i '/^#PubkeyAuthentication yes/s/^#//' /etc/ssh/sshd_config
sudo synosystemctl restart sshd.service

Check out this blog post for more details.

Oh My Bash!

The out of the box ssh experience of Synology is ok. But we can do better…

This basically involves configuring a ~/.bashrc.

I opted for Oh My Bash.

bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"

If you have forked the Oh My Bash repository:

cd ~/.oh-my-bash
git remote add mine https://github.com/Laoujin/oh-my-bash
git fetch mine
git branch -u mine/master
git pull

This created said ~/.bashrc which you will want to configure!

  • OSH_THEME: Pick a folder name in themes
  • completions: Tab autocomplete? Yes please!
  • aliases: You get ... as cd ../../ out of the box but there are many more.
  • plugins: bashmarks (=jump to location) is really cool! Run bm for help.

Use bash -l to reload your shell after having made changes.

Package Center

You probably want to install these packages. From the UI because synopkg doesn’t seem to provide a way to install an official package 😭

  • Text Editor
  • Git Server
  • Docker
  • Cloud Sync (Dropbox, GDrive, …)

After that I basically do everything with Docker but if you want some ready-made packages that are not in the official listing, be sure to checkout SynoCommunity.

Cloud Sync

I created a /volume1/Dropbox shared folder for Dropbox:

sudo synoshare --help
sudo synoshare --add Dropbox "Dropbox Cloud Sync" /volume1/Dropbox "" "users" "" 0 0

Git

Configuation

git config --global user.name ""
git config --global user.email ""

# And then I copy my ".common.gitconfig" file:
# https://github.com/Laoujin/dotfiles/blob/master/config/git/.common.gitconfig
# Windows
scp -P 22 -r ~/.common.gitconfig userName@192.168.1.x:~/

# NAS
git config --global include.path "~/.common.gitconfig"

# Overwrite your Windows autocrlf=true:
git config --global core.autocrlf false

You could also opt to create a symbolic link from your Cloud Sync .gitconfig.

ln -s /volume1/Dropbox/.common.gitconfig ~/.common.gitconfig
git config --global include.path "~/.common.gitconfig"

Github

For private repos and pushing stuff:

# On NAS this time!
ssh-keygen

Add the SSH Authentication key in Github Settings:

  • New SSH key
  • Paste the .pub file

Docker

To avoid having to sudo docker everything.

sudo synogroup --add docker
sudo synogroup --member docker $USER
sudo chown root:docker /var/run/docker.sock

Text Editor

It’s good for editing a config file here or there but also not for much more than that!

Visual Studio Code

In case you don’t like VIM 😀

version: '3'

services:
  openvscode-server:
    image: lscr.io/linuxserver/openvscode-server:latest
    container_name: openvscode-server
    environment:
      - PUID=1026
      - PGID=100
      - TZ=Europe/Brussels
      - CONNECTION_TOKEN= #optional
      - CONNECTION_SECRET= #optional
      - SUDO_PASSWORD=password #optional
      - SUDO_PASSWORD_HASH= #optional
    volumes:
      - ~/docker-configs/VSCode:/config
      - /volume1/Projects:/projects
    ports:
      - 3000:3000
    restart: unless-stopped

Other interesting reads
Tags: synology