[HOW-TO] Install Optware/OpenSSH as default SSHd Server

Discussion on setting up QNAP NAS products.
Post Reply
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by pwilson »

joogoo wrote:
pwilson wrote:
I don't own a TS-453, so I can't tell you for sure, but to create it on your NAS, it probably works like the TS-x70 series. The following commands should do it for you:

Code: Select all

mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0)6 /tmp/config
ln -f /tmp/config/autorun.sh /tmp/config/autorun.sh.OLD
rm -f /tmp/config/autorun.sh
touch /tmp/config/autorun.sh
chmod +x /tmp/config/autorun.sh
cat <<EOF >>/tmp/config/autorun.sh
#!/bin/sh
# AUTORUN.SH - "Boot strap"
# This script forces the NAS to run "/etc/config/autorun.sh" at every startup (if this file exists).
#
/etc/config/autorun.sh
touch /tmp/autorun.ran
# done
EOF
echo "unmounting /tmp/config..."
umount /tmp/config
touch /etc/config/autorun.sh
chmod +x /etc/config/autorun.sh
cat <<EOF1 >>/etc/config/autorun.sh
#!/bin/sh
#
# /etc/config/autorun.sh - These commands run at every NAS Startup
#
###  Add your commands here 


#done
EOF1
echo "Edit /etc/config/autorun.sh for all further changes to the autostart procedure of the NAS. 
#done

Warning: This "autorun.sh" solution is specific to newer Intel-based QNAP NAS models. This solution is not correct for QNAP any ARM-based model, or older Intel-based NAS Models. You can modify the /etc/config/autorun.sh script to your requirements thereafter.

I don't for the life of me understand why you would need an autorun.sh at all for this task in the first place. If you need to customize the OpenSSH startup, simply edit /opt/etc/init.d/S40sshd. After you have accomplished this, you will need to follow the instructions for: Running /opt/etc/init.d/* on startup in QNAPedia article: Install Optware IPKG.

Startup scripts located in /opt/etc/init.d/ will run at Optware startup if you follow the instructions in this QNAPedia article. (No "autorun.sh" required).
Many thanks !
mount -t ext2 $(/sbin/hal_app --get_boot_pd port_id=0)6 /tmp/config did the trick.
I've been able to mount the ramdisk and add the autorun.sh script.
It did worked well to run because I can see /tmp/autorun.ran every time I reboot the NAS.

But for now, I haven't succeeded to run automatically OpenSSH at startup but there should be something wrong in my autorun.
Here is the code of it if you don't mind helping again :

Code: Select all

#!/bin/sh
#
# /etc/config/autorun.sh - These commands run at every NAS Startup
#
###  Add your commands here

/opt/etc/init.d/S40sshd start #added line

#done
Thanks again for your help.
That is an absolutely horrible way to accomplish this. Why didn't you modify your Optware script like I suggested, so that it runs all your Optware "init scripts" at startup like it is designed to do? Simply follow the instructions for: Running /opt/etc/init.d/* on startup in QNAPedia article: Install Optware IPKG?

You do not need an "autorun.sh" file for this task at all. If you make the changes as instructed in that QNAPedia article, it will run "/opt/etc/init.d/S40sshd" for you automatically, along with any other Optware "init" scripts in that same /opt/etc/init.d/ directory.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
haima
First post
Posts: 1
Joined: Thu Feb 26, 2015 3:07 am

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by haima »

Dear Guru Wilson,

We have a QNAP model: TS-853 PRO and firmware 4.1.2. We are trying to configure the OpenSSH as the default SSHd Server but we encounter a few challenges.
We have managed to install as you helpfully suggested. However, it seems we fail to run it automatically upon restart. We couldn't figure out whether we need to set up an autorun.sh and if so, how to do it (which device should we mount?). Alternatively, should we edit somehow the /opt/etc/init.d/S40sshd file?
We are kind of lost now and could really use your help...

Many thanks in advance for efforts,
Haim and Eli
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by pwilson »

haima wrote:Dear Guru Wilson,

We have a QNAP model: TS-853 PRO and firmware 4.1.2. We are trying to configure the OpenSSH as the default SSHd Server but we encounter a few challenges.
We have managed to install as you helpfully suggested. However, it seems we fail to run it automatically upon restart. We couldn't figure out whether we need to set up an autorun.sh and if so, how to do it (which device should we mount?). Alternatively, should we edit somehow the /opt/etc/init.d/S40sshd file?
We are kind of lost now and could really use your help...

Many thanks in advance for efforts,
Haim and Eli
As stated two messages earlier in this thread. You do not need an "autorun.sh" file for this task at all. If you make the changes as instructed in the Running /opt/etc/init.d/* on startup in QNAPedia article: Install Optware IPKG. , it will run "/opt/etc/init.d/S40sshd" for you automatically, along with any other Optware "init" scripts in that same /opt/etc/init.d/ directory.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
User avatar
MrVideo
Experience counts
Posts: 4742
Joined: Fri May 03, 2013 2:26 pm

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by MrVideo »

pwilson wrote:As stated two messages earlier in this thread. You do not need an "autorun.sh" file for this task at all. If you make the changes as instructed in the Running /opt/etc/init.d/* on startup in QNAPedia article: Install Optware IPKG. , it will run "/opt/etc/init.d/S40sshd" for you automatically, along with any other Optware "init" scripts in that same /opt/etc/init.d/ directory.
There is no need to do anything. QNAPware apps that are daemons, like ssh, are automatically set up to start.

There are only two that I installed, sshd and rsyncd. But rsyncd did not start because I believe that it won't if there is already a PID for rsyncd, based upon looking at the QNAPware's startup script. Since the system rsyncd gets started first, another one isn't started (for obvious reasons). I'll have to make it simple and rename the init.d rsync startup scripts so that they aren't found. :mrgreen:

But, if /etc/rcS.d is parsed alphabetically, the QNAPware scripts get parsed first. I haven't gone looking, but it might be that the system script that starts rsyncd might kill off any running daemons first. In any event, I'm not worried about it at the moment. Getting the OpenSSH daemon running is what I was after.
QTS MANUALS
Submit QNAP Support Ticket - QNAP Tutorials, FAQs, Downloads, Wiki - Product Support Status - Moogle's QNAP FAQ help V2
Asking a question, include the following
(Thanks to Toxic17)
QNAP md_checker nasreport (release 20210309)
===============================
Model: TS-869L -- RAM: 3G -- FW: QTS 4.1.4 Build 20150522 (used for data storage)
WD60EFRX-68L0BN1(x1)/68MYMN1(x7) Red HDDs -- RAID6: 8x6TB -- Cold spare: 1x6TB
Entware
===============================
Model: TS-451A -- RAM: 2G -- FW: QTS 4.5.2 Build 20210202 (used as a video server)
WL3000GSA6472(x3) White label NAS HDDs -- RAID5: 3x3TB
Entware -- MyKodi 17.3 (default is Kodi 16)
===============================
My 2017 Total Solar Eclipse Photos | My 2019 N. Ireland Game of Thrones tour
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by pwilson »

MrVideo wrote:
pwilson wrote:As stated two messages earlier in this thread. You do not need an "autorun.sh" file for this task at all. If you make the changes as instructed in the Running /opt/etc/init.d/* on startup in QNAPedia article: Install Optware IPKG. , it will run "/opt/etc/init.d/S40sshd" for you automatically, along with any other Optware "init" scripts in that same /opt/etc/init.d/ directory.
There is no need to do anything. QNAPware apps that are daemons, like ssh, are automatically set up to start.

There are only two that I installed, sshd and rsyncd. But rsyncd did not start because I believe that it won't if there is already a PID for rsyncd, based upon looking at the QNAPware's startup script. Since the system rsyncd gets started first, another one isn't started (for obvious reasons). I'll have to make it simple and rename the init.d rsync startup scripts so that they aren't found. :mrgreen:

But, if /etc/rcS.d is parsed alphabetically, the QNAPware scripts get parsed first. I haven't gone looking, but it might be that the system script that starts rsyncd might kill off any running daemons first. In any event, I'm not worried about it at the moment. Getting the OpenSSH daemon running is what I was after.
Yes, unlike QNAP, zyxmon, built the "init.d" subsystem properly in QNAPware, so that nonsense isn't required with QNAPware/Entware. Check out:

Code: Select all

ls -alF /Apps/opt/etc/init.d
From my NAS:

Code: Select all

ls -alF /Apps/opt/etc/init.d
total 32
drwxr-xr-x+ 2 admin administrators 4096 Jun 21 01:14 ./
drwxr-xr-x+ 6 admin administrators 4096 Jul  9 11:04 ../
-rwxrwx---+ 1 admin administrators 2786 Apr 27 04:46 rc.func*
-rwxrwx---+ 1 admin administrators  851 Apr 27 04:46 rc.unslung*
-rwxrwx---+ 1 admin administrators  222 Mar  2 05:21 S10xinetd*
-rwxr-xr-x+ 1 admin administrators  707 Jun  1 15:05 S40sshd*

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
User avatar
MrVideo
Experience counts
Posts: 4742
Joined: Fri May 03, 2013 2:26 pm

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by MrVideo »

pwilson wrote:Yes, unlike QNAP, zyxmon, built the "init.d" subsystem properly in QNAPware, so that nonsense isn't required with QNAPware/Entware. Check out:

Code: Select all

ls -alF /Apps/opt/etc/init.d
From my NAS:

Code: Select all

ls -alF /Apps/opt/etc/init.d
total 32
drwxr-xr-x+ 2 admin administrators 4096 Jun 21 01:14 ./
drwxr-xr-x+ 6 admin administrators 4096 Jul  9 11:04 ../
-rwxrwx---+ 1 admin administrators 2786 Apr 27 04:46 rc.func*
-rwxrwx---+ 1 admin administrators  851 Apr 27 04:46 rc.unslung*
-rwxrwx---+ 1 admin administrators  222 Mar  2 05:21 S10xinetd*
-rwxr-xr-x+ 1 admin administrators  707 Jun  1 15:05 S40sshd*
I have sshd and rsyncd in my location.

What QNAP has for the rcS.d/rcK.d/init.d directories is correct, except that they don't have the standard rc directories numbered, based on the run level, where all of the K and S links are placed in the same directory. But, since a NAS box doesn't have run levels, they aren't needed.

zyxmon still has to place links in the rcS.d and rcK.d directories. I'm guessing that they didn't place the actual scripts in the system init.d location in case QNAP to do something that would overwrite them. The odds are slim that a file named S40ssh.sh would be overwritten by QNAP, but maybe something else might. Safer to put them in their own area.

Not sure why they named the files so that they start with "S", considering that they are also the kill scripts. Using a "Q" instead would have made more sense.

Anyway, it works.
QTS MANUALS
Submit QNAP Support Ticket - QNAP Tutorials, FAQs, Downloads, Wiki - Product Support Status - Moogle's QNAP FAQ help V2
Asking a question, include the following
(Thanks to Toxic17)
QNAP md_checker nasreport (release 20210309)
===============================
Model: TS-869L -- RAM: 3G -- FW: QTS 4.1.4 Build 20150522 (used for data storage)
WD60EFRX-68L0BN1(x1)/68MYMN1(x7) Red HDDs -- RAID6: 8x6TB -- Cold spare: 1x6TB
Entware
===============================
Model: TS-451A -- RAM: 2G -- FW: QTS 4.5.2 Build 20210202 (used as a video server)
WL3000GSA6472(x3) White label NAS HDDs -- RAID5: 3x3TB
Entware -- MyKodi 17.3 (default is Kodi 16)
===============================
My 2017 Total Solar Eclipse Photos | My 2019 N. Ireland Game of Thrones tour
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by pwilson »

MrVideo wrote:
pwilson wrote:Yes, unlike QNAP, zyxmon, built the "init.d" subsystem properly in QNAPware, so that nonsense isn't required with QNAPware/Entware. Check out:

Code: Select all

ls -alF /Apps/opt/etc/init.d
From my NAS:

Code: Select all

ls -alF /Apps/opt/etc/init.d
total 32
drwxr-xr-x+ 2 admin administrators 4096 Jun 21 01:14 ./
drwxr-xr-x+ 6 admin administrators 4096 Jul  9 11:04 ../
-rwxrwx---+ 1 admin administrators 2786 Apr 27 04:46 rc.func*
-rwxrwx---+ 1 admin administrators  851 Apr 27 04:46 rc.unslung*
-rwxrwx---+ 1 admin administrators  222 Mar  2 05:21 S10xinetd*
-rwxr-xr-x+ 1 admin administrators  707 Jun  1 15:05 S40sshd*
I have sshd and rsyncd in my location.

What QNAP has for the rcS.d/rcK.d/init.d directories is correct, except that they don't have the standard rc directories numbered, based on the run level, where all of the K and S links are placed in the same directory. But, since a NAS box doesn't have run levels, they aren't needed.

zyxmon still has to place links in the rcS.d and rcK.d directories. I'm guessing that they didn't place the actual scripts in the system init.d location in case QNAP to do something that would overwrite them. The odds are slim that a file named S40ssh.sh would be overwritten by QNAP, but maybe something else might. Safer to put them in their own area.

Not sure why they named the files so that they start with "S", considering that they are also the kill scripts. Using a "Q" instead would have made more sense.

Anyway, it works.
I wasn't complaining about the standard /etc/config/init.d directory, but rather the fact that QNAP didn't bother to setup the Optware init.d system properly. Users wanting to use the Optware init.d subsystem, need to modify their systems to enable it. Check out the "Running /opt/etc/init.d/* on startup" section of QNAPedia article: Install Optware IPKG

zyxmon's QNAPware/Entware package does it properly. No NASAdmin effort is required whatsoever, if you install an Entware daemon, it is automagically installed in /Apps/opt/etc/init.d.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
User avatar
MrVideo
Experience counts
Posts: 4742
Joined: Fri May 03, 2013 2:26 pm

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by MrVideo »

pwilson wrote:I wasn't complaining about the standard /etc/config/init.d directory, but rather the fact that QNAP didn't bother to setup the Optware init.d system properly. Users wanting to use the Optware init.d subsystem, need to modify their systems to enable it. Check out the "Running /opt/etc/init.d/* on startup" section of QNAPedia article: Install Optware IPKG

zyxmon's QNAPware/Entware package does it properly. No NASAdmin effort is required whatsoever, if you install an Entware daemon, it is automagically installed in /Apps/opt/etc/init.d.
Ah, got it. Misunderstood. I had looked at that setup link and discovered that it wasn't for me because it was set up.
QTS MANUALS
Submit QNAP Support Ticket - QNAP Tutorials, FAQs, Downloads, Wiki - Product Support Status - Moogle's QNAP FAQ help V2
Asking a question, include the following
(Thanks to Toxic17)
QNAP md_checker nasreport (release 20210309)
===============================
Model: TS-869L -- RAM: 3G -- FW: QTS 4.1.4 Build 20150522 (used for data storage)
WD60EFRX-68L0BN1(x1)/68MYMN1(x7) Red HDDs -- RAID6: 8x6TB -- Cold spare: 1x6TB
Entware
===============================
Model: TS-451A -- RAM: 2G -- FW: QTS 4.5.2 Build 20210202 (used as a video server)
WL3000GSA6472(x3) White label NAS HDDs -- RAID5: 3x3TB
Entware -- MyKodi 17.3 (default is Kodi 16)
===============================
My 2017 Total Solar Eclipse Photos | My 2019 N. Ireland Game of Thrones tour
aleba89
New here
Posts: 3
Joined: Wed Oct 28, 2015 3:28 pm

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by aleba89 »

Hi to All!
I want to change ssh daemon on my qnap ts-231+ and I tryed to follow guides on forum but I hadn't success.
My Qnap has 4.2.0 build 1023 firmware

Can you help me to reach my goal?

Thanks to all!
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by pwilson »

aleba89 wrote:Hi to All!
I want to change ssh daemon on my qnap ts-231+ and I tryed to follow guides on forum but I hadn't success.
My Qnap has 4.2.0 build 1023 firmware

Can you help me to reach my goal?

Thanks to all!
Which part are you stuck on?

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
aleba89
New here
Posts: 3
Joined: Wed Oct 28, 2015 3:28 pm

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by aleba89 »

I mount mtdblock5 and i create autorun.sh and login.sh in accord with this topic but doesn't work

http://wiki.qnap.com/wiki/How_To_Replac ... th_OpenSSH

Note: On my qnap i've installed QNAPwere end openssh-server packet

thanks
User avatar
pwilson
Guru
Posts: 22533
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada (UTC-08:00)

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by pwilson »

aleba89 wrote:I mount mtdblock5 and i create autorun.sh and login.sh in accord with this topic but doesn't work

http://wiki.qnap.com/wiki/How_To_Replac ... th_OpenSSH

Note: On my qnap i've installed QNAPwere end openssh-server packet

thanks
You are in the wrong thread then. This thread is an alternative to the dangerous advice provided in QNAPedia article: How To Replace SSH Daemon With OpenSSH. Please review the first message in this thread for instructions.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-470 Pro w/ 4 * Western Digital WD30EFRX WD Reds (RAID5) - - Single 8.1TB Storage Pool FW: QTS 4.2.0 Build 20151023 - Kali Linux v1.06 (64bit)
Forums: View My Profile - Search My Posts - View My Photo - View My Location - Top Community Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs

Please review: When you're asking a question, please include the following.
aleba89
New here
Posts: 3
Joined: Wed Oct 28, 2015 3:28 pm

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by aleba89 »

Very thanks. I've resolved my problem!
Thanks
ilivlad
New here
Posts: 8
Joined: Mon May 28, 2012 10:15 am

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by ilivlad »

Hello!
I reinstall my TS112 but now I have a few issues.

I used Optware earlier and now I installed Qnapware.
I was trying to install Openssh by adapting first message of this thread but I cant login.
Original sshd is on 12121 and working.
I installed Openssh-server and got it going with autorun.sh. (/Apps/opt/sbin/sshd -f /Apps/opt/etc/ssh/sshd_config -p 22).
After rebooting i have both sshd's running but trying to login to the later one, i cannot.

Using my admin username and password doesnt work.
Can yoiu help me please?
Thank you!
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: [HOW-TO] Install Optware/OpenSSH as default SSHd Server

Post by schumaku »

Checked the sshd_cofnig file?

Already tried to use a verbose ssh login, ie. from a Linux system?

# ssh -vvv admin@ts-119
OpenSSH_7.0p1, OpenSSL 1.0.1r 28 Jan 2016
...
ilivlad wrote:I installed Openssh-server and got it going with autorun.sh. (/Apps/opt/sbin/sshd -f /Apps/opt/etc/ssh/sshd_config -p 22).
I was under the impression that Entware-NG (and Entware/QNAPware before) does have it's own init.d system automatically starting services installed and configured.
Post Reply

Return to “Turbo Station Installation & Setup”