Annoying issues with SSH'ing to NAS

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.
Post Reply
afjochnick
Starting out
Posts: 19
Joined: Sun Apr 26, 2009 3:55 am

Annoying issues with SSH'ing to NAS

Post by afjochnick » Mon Apr 12, 2021 8:15 pm

I am using my NAS as a server, i.e. i run tomcat and other things on it and frequently need to ssh in and do stuff.


3 things that really degrade my experience are:

1. i cannot do any shortcuts, for example "cdl" as an alias for something, because edits to bash_profile is prevented.

2. In the latest versions, i get some "menu" when i SSH in and i have to press "Q" and "Y" every single time.

3. The command history is cleared on every reboot, i.e. when i press arrow up, my commands are not remembered.

Is there any way to sort out any of these things?

User avatar
dolbyman
Guru
Posts: 22742
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Annoying issues with SSH'ing to NAS

Post by dolbyman » Mon Apr 12, 2021 9:21 pm

2. Can be deactivted in GUI

Control Panel > System > General Settings > Console Management > Enable Console Management

User avatar
OneCD
Ask me anything
Posts: 8972
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Annoying issues with SSH'ing to NAS

Post by OneCD » Tue Apr 13, 2021 2:27 am

afjochnick wrote:
Mon Apr 12, 2021 8:15 pm
1. i cannot do any shortcuts, for example "cdl" as an alias for something, because edits to bash_profile is prevented.
Add your aliases to [/etc/profile] instead. Changes to this file do not persist between reboots, so be prepared to add them again after each startup. ;)
afjochnick wrote:
Mon Apr 12, 2021 8:15 pm
3. The command history is cleared on every reboot, i.e. when i press arrow up, my commands are not remembered.
Correct, the bash history is not retained, because the history file is also not stored in a persistent location. Same as [/etc/profile].

If you'd like to keep your history between power-on sessions, you'll need to move [/root/.bash_history] to a persistent location, and restore it into [/root] after each reboot (suggest creating a symlink in [/root] pointing to your persistent file).

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

afjochnick
Starting out
Posts: 19
Joined: Sun Apr 26, 2009 3:55 am

Re: Annoying issues with SSH'ing to NAS

Post by afjochnick » Mon Apr 19, 2021 3:10 pm

HI both of you thanks for responding.

Dolbyman, thanks had missed that, that's something at least..

OneCD, thanks i knew about those "workarounds", that's kind of what i meant with "prevented". I power boot every day. My TS259B Mini sounds like a ** jet engine even when it's idle (i created another thread about that...), and its in our apartment. Therefor my wife has kindly requested that we power it down every night.
It's really frustrating and i will checkout their main competitor to see if it's more silent, and if it's possible to conduct sane terminal activities there.

Mousetick
Been there, done that
Posts: 946
Joined: Thu Aug 24, 2017 10:28 pm

Re: Annoying issues with SSH'ing to NAS

Post by Mousetick » Fri Apr 23, 2021 4:58 pm

1. Create a regular user.
2. Make that user a member of administrators group.
3. Allow that user to login via SSH (Control Panel > Network & File Services > Telnet / SSH)

Now this user's home directory is stored on persistent storage and you can customize its shell as you see fit and not lose your customizations between reboots.

If you need superuser privileges, the setup process is a little more involved, but it can be one-time set-and-forget thing. The goal is to use sudo which is preinstalled on QNAP but its default configuration is "hard-coded" in firmware. So a workaround is necessary.

The hardcoded configuration is located at /usr/etc/sudoers.

4. Copy /usr/etc/sudoers to /etc/config. This directory's contents are stored on persistent HD storage.
5. Edit /etc/config/sudoers and add your user.

Now the tricky part:

6. Make a symbolic link from /etc/config/sudoers to /usr/etc/sudoers, so that sudo uses your modified copy of sudoers:

Code: Select all

$ ls -l /usr/etc/sudoers
lrwxrwxrwx 1 admin administrators 19 Apr 22 23:59 /usr/etc/sudoers -> /etc/config/sudoers
The link will be lost after each reboot, so you either need to recreate it manually each time (while logged in as admin user), or you can use a shell script to recreate it automatically at boot time, using the autorun mechanism (Control Panel > System > Hardware > General > Run user defined processes during startup).

For setting up the autorun mechanism, I recommend @OneCD's excellent create-autorun script which makes it very easy and foolproof.

Post Reply

Return to “Miscellaneous”