Skip to content

Instantly share code, notes, and snippets.

@walkerjeffd
Last active September 27, 2025 02:50
Show Gist options
  • Save walkerjeffd/374750c366605cd5123d to your computer and use it in GitHub Desktop.
Save walkerjeffd/374750c366605cd5123d to your computer and use it in GitHub Desktop.

Revisions

  1. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Synology-Diskstation-Git.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Configure Synology NAS as Git Server
    ------------------------------------

    Instructions for setting up a git server on a Synology NAS with Diskstation
    Instructions for setting up a git server on a Synology NAS with Diskstation. Specifically, I am using a DS414 with DSM 5.0.

    ### Set Up User and Folder

  2. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions Synology-Diskstation-Git.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,17 @@
    Configure Synology NAS as Git Server
    ------------------------------------

    Instructions for setting up a git server on a Synology NAS with Diskstation

    - Create user `gituser` on NAS (with File Station and WebDAV privilages)
    - Add new shared folder for the repos called `git` (located at `/volume1/git`) with read/write access for `gituser` and `admin`
    ### Set Up User and Folder

    - Create user `gituser` via Diskstation interface (with File Station and WebDAV privilages)
    - Add new shared folder called `git` (located at `/volume1/git`) with read/write access for `gituser` and `admin`. This folder will hold all the repos.
    - Install Git Server package via Diskstation
    - Open Git Server and allow `gituser` permissions
    - Enable SSH access on Diskstation (Control Panel > Terminal & SNMP > Enable SSH Service)

    Configure SSH Access
    ### Configure SSH Access

    - create `~/.ssh` folder for gituser on server

    @@ -21,7 +26,7 @@ mkdir /volume1/homes/gituser/.ssh
    scp ~/.ssh/id_rsa.pub [email protected]:/volume1/homes/gituser/.ssh
    ```

    - ssh as `root` and rename `id_rsa.pub` to `authorized_keys` on NAS (or append if already exists, `cat id_rsa.pub >> authorized_keys`)
    - connect via SSH as `root` and rename `id_rsa.pub` to `authorized_keys` on NAS (or append if already exists, `cat id_rsa.pub >> authorized_keys`)

    ```
    ssh [email protected]
    @@ -37,8 +42,7 @@ chmod 700 .ssh
    chmod 644 .ssh/authorized_keys
    ```


    ## Setting up a New Repo on NAS
    ### Set Up New Repo on NAS

    - create bare repo as root

    @@ -53,7 +57,7 @@ git update-server-info

    NOTE: I'm not entirely sure if `git update-server-info` must be run for each repo or just initially. It seems to work without running this command, but I'm suspcicious that it might cause problems later.

    ## Add NAS as Remote for Local Repo
    ### Add NAS as Remote for Local Repo

    - Clone repo from NAS

  3. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 12 additions and 25 deletions.
    37 changes: 12 additions & 25 deletions Synology-Diskstation-Git.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Instructions for setting up a git server on a Synology NAS with Diskstation

    - Create user `gituser` on NAS (with File Station and WebDAV privilages)
    - Add new shared folder for the repos `volume1/homes/gituser/git` with read/write access for `gituser` and `admin`
    - Add new shared folder for the repos called `git` (located at `/volume1/git`) with read/write access for `gituser` and `admin`
    - Install Git Server package via Diskstation
    - Open Git Server and allow `gituser` permissions
    - Enable SSH access on Diskstation (Control Panel > Terminal & SNMP > Enable SSH Service)
    @@ -21,14 +21,14 @@ mkdir /volume1/homes/gituser/.ssh
    scp ~/.ssh/id_rsa.pub [email protected]:/volume1/homes/gituser/.ssh
    ```

    - rename `id_rsa.pub` to `authorized_keys` on NAS (or append if already exists, `cat id_rsa.pub >> authorized_keys`)
    - ssh as `root` and rename `id_rsa.pub` to `authorized_keys` on NAS (or append if already exists, `cat id_rsa.pub >> authorized_keys`)

    ```
    ssh admin@diskstation.local
    ssh root@diskstation.local
    mv /volume1/homes/gituser/.ssh/id_rsa.pub /volume1/homes/gituser/.ssh/authorized_keys
    ```

    - change permissions as root
    - change permissions while logged in as root

    ```
    cd /volume1/homes/gituser/
    @@ -37,22 +37,6 @@ chmod 700 .ssh
    chmod 644 .ssh/authorized_keys
    ```

    - change ssh config to allow for key validation

    ```
    ssh [email protected]
    cd /volume1/homes/gituser
    vim /etc/ssh/sshd_config
    ```

    WARNING: If you happen to do something foolish here, you may lock yourself out of being able to connect via SSH as gituser, root, admin, and everyone else. In the event this happens, you can change the sshd_config file back by using telnet to connect instead of SSH (make sure telnet is enabled via the web interface).

    - uncomment these lines (save in vim `:w` and then quit `:q`)

    ```
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys
    ```

    ## Setting up a New Repo on NAS

    @@ -61,22 +45,25 @@ AuthorizedKeysFile .ssh/authorized_keys
    ```
    ssh [email protected]
    cd /volume1/git/
    git --bare init <git-repo>.git
    chown -R gituser:users gitproject.git
    cd <git-repo>.git
    git --bare init <repo-name>.git
    chown -R gituser:users <repo-name>.git
    cd <repo-name>.git
    git update-server-info
    ```

    NOTE: I'm not entirely sure if `git update-server-info` must be run for each repo or just initially. It seems to work without running this command, but I'm suspcicious that it might cause problems later.

    ## Add NAS as Remote for Local Repo

    - Clone repo from NAS

    ```
    git clone ssh://[email protected]/volume1/git/myproject.git
    git clone ssh://[email protected]/volume1/git/<repo-name>.git
    ```


    References:
    ## References

    http://blog.osdev.org/git/2014/02/13/using-git-on-a-synology-nas.html
    http://stackoverflow.com/questions/20074692/set-up-git-on-a-nas-with-synologys-official-package
    http://www.heidilux.com/2014/02/setup-git-server-synology-nas/
  4. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Synology-Diskstation-Git.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    Instructions for setting up a git server on a Synology NAS with Diskstation

    - Create user `gituser` on NAS (with WebDAV privilages)
    - Create user `gituser` on NAS (with File Station and WebDAV privilages)
    - Add new shared folder for the repos `volume1/homes/gituser/git` with read/write access for `gituser` and `admin`
    - Install Git Server package via Diskstation
    - Open Git Server and allow `gituser` permissions
  5. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions Synology-Diskstation-Git.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,10 @@
    Instructions for setting up a git server on a Synology NAS with Diskstation

    - Create user `gituser` on NAS (with WebDAV privilages)
    - Add new shared folder for the repos `volume1/homes/gituser/git` with read/write access for `gituser` and `admin`
    - Install Git Server package via Diskstation
    - Open Git Server and allow `gituser` permissions
    - Enable SSH access on Diskstation (Control Panel > Terminal & SNMP > Enable SSH Service)
    - Create user `gituser` on NAS (with WebDAV privilages)
    - Add new shared folder called `git` (e.g. `/volume1/git`) with read/write access for `gituser` and `admin`

    Configure SSH Access

  6. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Synology-Diskstation-Git.md
    Original file line number Diff line number Diff line change
    @@ -44,6 +44,8 @@ cd /volume1/homes/gituser
    vim /etc/ssh/sshd_config
    ```

    WARNING: If you happen to do something foolish here, you may lock yourself out of being able to connect via SSH as gituser, root, admin, and everyone else. In the event this happens, you can change the sshd_config file back by using telnet to connect instead of SSH (make sure telnet is enabled via the web interface).

    - uncomment these lines (save in vim `:w` and then quit `:q`)

    ```
  7. walkerjeffd renamed this gist Jul 17, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -76,3 +76,4 @@ git clone ssh://[email protected]/volume1/git/myproject.git
    References:
    http://blog.osdev.org/git/2014/02/13/using-git-on-a-synology-nas.html
    http://stackoverflow.com/questions/20074692/set-up-git-on-a-nas-with-synologys-official-package
    http://www.heidilux.com/2014/02/setup-git-server-synology-nas/
  9. walkerjeffd revised this gist Jul 17, 2014. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -53,11 +53,24 @@ AuthorizedKeysFile .ssh/authorized_keys

    ## Setting up a New Repo on NAS



    - create bare repo as root

    ```
    ssh [email protected]
    cd /volume1/git/
    git --bare init <git-repo>.git
    chown -R gituser:users gitproject.git
    cd <git-repo>.git
    git update-server-info
    ```

    ## Add NAS as Remote for Local Repo

    - Clone repo from NAS

    ```
    git clone ssh://[email protected]/volume1/git/myproject.git
    ```


    References:
  10. walkerjeffd renamed this gist Jul 17, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. walkerjeffd created this gist Jul 17, 2014.
    65 changes: 65 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    Instructions for setting up a git server on a Synology NAS with Diskstation

    - Install Git Server package via Diskstation
    - Enable SSH access on Diskstation (Control Panel > Terminal & SNMP > Enable SSH Service)
    - Create user `gituser` on NAS (with WebDAV privilages)
    - Add new shared folder called `git` (e.g. `/volume1/git`) with read/write access for `gituser` and `admin`

    Configure SSH Access

    - create `~/.ssh` folder for gituser on server

    ```
    ssh [email protected]
    mkdir /volume1/homes/gituser/.ssh
    ```

    - copy public rsa key from local computer to gituser account on server

    ```
    scp ~/.ssh/id_rsa.pub [email protected]:/volume1/homes/gituser/.ssh
    ```

    - rename `id_rsa.pub` to `authorized_keys` on NAS (or append if already exists, `cat id_rsa.pub >> authorized_keys`)

    ```
    ssh [email protected]
    mv /volume1/homes/gituser/.ssh/id_rsa.pub /volume1/homes/gituser/.ssh/authorized_keys
    ```

    - change permissions as root

    ```
    cd /volume1/homes/gituser/
    chown -R gituser:users .ssh
    chmod 700 .ssh
    chmod 644 .ssh/authorized_keys
    ```

    - change ssh config to allow for key validation

    ```
    ssh [email protected]
    cd /volume1/homes/gituser
    vim /etc/ssh/sshd_config
    ```

    - uncomment these lines (save in vim `:w` and then quit `:q`)

    ```
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys
    ```

    ## Setting up a New Repo on NAS




    ## Add NAS as Remote for Local Repo



    References:
    http://blog.osdev.org/git/2014/02/13/using-git-on-a-synology-nas.html
    http://stackoverflow.com/questions/20074692/set-up-git-on-a-nas-with-synologys-official-package