How can I work with command line on synology? [closed]
Asked Answered
D

6

31

How do I access the command line interface on a Synology NAS.

Specifically, I am trying to access the command line on a Synology DS1520+, running DSM 7.1, so I can enter the command: sudo shutdown -h, so I can power down the NAS remotely.

I am pretty sure I should use SSH and unix/linux style commands.

Defloration answered 29/2, 2016 at 8:3 Comment(0)
H
24

You can use your favourite telnet (not recommended) or ssh (recommended) application to connect to your Synology box and use it as a terminal.

  1. Enable the command line interface (CLI) from the Network Services
  2. Define the protocol and the user and make sure the user has password set
  3. Access the CLI

If you need more detailed instruction read https://www.synology.com/en-global/knowledgebase/DSM/help/DSM/AdminCenter/system_terminal

Heptagon answered 15/3, 2016 at 15:10 Comment(0)
M
10

I use GateOne from the synocommunity.

Go into settings in Package Center and add http://packages.synocommunity.com/ as a package source. Then you should be able to add it easily via Package Center.

Mussulman answered 13/4, 2016 at 7:17 Comment(4)
currently it's broken with DSM 6, but they're working on itCasualty
link --> "Bad Request - The browser (or proxy) sent a request that this server could not understand." (and by https:443 too); Btw, v20151116-6 last. EOL?Intake
That one (I tried the latest version 20171125-8 on offer) still depends on Python 2.7, which has reached its end of support in January 2020.Shiverick
GateOne is a generic SSH client with a web user interface; to connect to Synology itself, it also goes through SSH. The nice thing is that you can also connect to any other host through it, but I was specificially looking for terminal acccess to troubleshoot SSH problems, where GateOne is of no use, unfortunately.Shiverick
O
10

The current windows 10 (Version 1803 (OS Build 17134.1)) has SSH built in. With that, just enable SSH from the Control Panel, Terminal & SNMP, be sure you are using an account in the Administrator's group, and you're all set.

Launch Powershell or CMD, enter ssh yourAccountName@diskstation

The first time it will cache off your certificate.

EDIT:

Further detailed explanations can be found on the synology docs page:

How to login to DSM with root permission via SSH Telnet

Orchidaceous answered 6/5, 2018 at 1:28 Comment(0)
C
8

for my example:

Windows XP ---> Synology:DS218+

  • Step1:
        > DNS: Control Panel (控制台)
             > Terminal & SNMP(終端機 & SNMP)
  • Step2:
        Enable Telnet service (啟動 Telnet 功能)
        or Enable SSH Service (啟動 SSH 功能)


    enter image description here
    enter image description here


  • Step3: Launch the terminal on Windows (or via executing

        cmd
    to launch the terminal)
    enter image description here


  • Step4: type: telnet your_nas_ip_or_domain_name, like below

        telnet 192.168.1.104
    enter image description here



  • Step5:
    demo a terminal application, like compiling the Java code

    Fzz login: tsungjung411

    Password:

    # shows the current working directory (顯示目前的工作目錄)
    $ pwd
    /var/services/homes/tsungjung411


    # edit a Java file (via vi), then compile and run it 
    # (透過 vi 編輯 Java 檔案,然後編譯和執行)
    $ vi Main.java

    # show the file content (顯示檔案內容)
    $ cat Main.java
    public class Main {
        public static void main(String [] args) {
            System.out.println("hello, World!");
        }
    }

    # compiles the Java file (編譯 Java 檔案)
    javac Main.java

    # executes the Java file (執行 Java 檔案)
    $ java Main
    hello, World!

    # shows the file list (顯示檔案清單)
    $ ls
    CloudStation  Main.class  Main.java  www

enter image description here


    # shows the JRE version on this Synology Disk Station
    $ java -version
    openjdk version "1.8.0_151"
    OpenJDK Runtime Environment (IcedTea 3.6.0) (linux-gnu build 1.8.0_151-b12)
    OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)




  • Step6:
    demo another terminal application, like running the Python code

    $ python
    Python 2.7.12 (default, Nov 10 2017, 20:30:30)
    [GCC 4.9.3 20150311 (prerelease)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    >>> import sys
    >>>
    >>> # shows the the python version
    >>> print(sys.version)
    2.7.12 (default, Nov 10 2017, 20:30:30)
    [GCC 4.9.3 20150311 (prerelease)]
    >>>
    >>> import os
    >>>
    >>> # shows the current working directory
    >>> print(os.getcwd())
    /volume1/homes/tsungjung411

enter image description here


    $ # launch Python 3
    $ python3
    Python 3.5.1 (default, Dec  9 2016, 00:20:03)
    [GCC 4.9.3 20150311 (prerelease)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>




Chipmunk answered 3/12, 2017 at 6:30 Comment(1)
This was the clearest answer, which worked for me. Thank you very much.Rema
A
1

I used Powershell under Windows 10 as suggested above, simply because it allows me to paste extremely long command lines that I have edited in another program.

Autochthon answered 12/3, 2021 at 22:12 Comment(0)
C
0

On top of @Peter's answer above, I strongly suggest to install some additional packaging system - Entware seems to be good, stable, still maintained and working on the latest DSM 7.

https://github.com/Entware/Entware/wiki/Install-on-Synology-NAS

With this, you can then install additional packages as you are used to on any other common Linux distribution.

Carotenoid answered 30/11, 2021 at 23:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.