Page 1 of 1

QNAP – How to set the VNC Password for Linux Station

QNAP – How to set the VNC Password for Linux Station
   30

For modern and more powerful QNAP devices, you can now run a complete Linux environment on your NAS. In this case by using Linux Station which basically runs a Ubuntu variant.

Since Linux Station is not really running as a virtual machine, it runs pretty fast. You can even hookup a HDMI monitor and a USB mouse and Keyboard to your QNAP and use it as a workstation. But most of us do not use their QNAP that way. Instead you can access Linux Station through their webbrowser, or … VNC.

VNC access comes with a challenge though. What the heck is the password? No matter what you do in the remote desktop settings, the password is fully ignored.

In this short article I’ll show you how to set a password – albeit in a not so conventional way.




Get started with Linux Station

Obviously this article is not about how to start Linux Station, but I’ll give you the quick steps.

  1. Make sure your QNAP model supports Linux Station!
    If you have an older or lower powered QNAP, like with an ARM or Atom based CPU, then you can forget about this option – Linux Station is not supported on your QNAP. Sorry.
  2. Install Linux Station on your QNAP.
    Open the “App Center” and find “Linux Station“. Click “Install” to add it to your QNAP. It’s free!
  3. Install Ubuntu on your Linux Station.
    Open the “Linux Station” app and select “Install Ubuntu 16.04 add-on from Linux Containers website“.
    At the time that I’m writing this you can get Ubuntu 14.04, Ubuntu 16.04 and Ubuntu Kylin 16.04 (Chinese Ubuntu).
    Obviously this may change in the future.

 

OK give it a whirl. To not have to drag a monitor, mouse and keyboard to your QNAP, you can use the remote desktop feature which runs in your browser. In essence this is simply VNC. In the screenshot below: check the “Enable Remote Desktop” option. Just below that you will see the link that will open the remote desktop in your browser.

QNAP - Linux Station

QNAP – Linux Station

I want to use VNC!

So, what bothered me about the browser approach is that it’s slow. OK for a few clicks, but not OK if you want to do more.
Also, the link only seems to work when you’re actually logged into the QNAP web-interface. Not practical for quick access.

In essence this is all based on VNC (the remote access) so why not use a regular (faster) VNC client?

It took some effort to find out what the password was. I have seen several posts pointing to methods that no longer seem to work, and then I noticed that there is a well hidden file with the password. To access Terminal, first click the link in the lower right corner that says “Please use the following URL“, so you can access Ubuntu.

After that you can work in Linux Station through your browser, there you can open a Terminal window and execute the following:


sudo more /tmp/.qnap/vncpassword

It will show the password needed to connect with VNC – give it a try. I used MacOS ScreenSharing but feel free to use any VNC client.

What is the IP address of Linux Station? 

The IP address can be seen in Linux Station, see screenshot above, just under the bold blue words “Remote connection“.

Awesome that worked!
Ehm … not entirely … there are 2 major problems with this password;

  1. It one of those goofy random passwords that nobody can remember.
  2. After restarting Linux Station or the Ubuntu you’re running, the password changes.

The first one I can deal with the second one … yikes!

Set your own VNC Password for Linux Station

Well, it seems that Linux Station, or maybe more correct the Ubuntu setup, is generating a random password each time it starts for VNC access.

With the following steps we can make that our own – all these steps are done in a terminal window in Linux Station!

Create a service that creates (overwrites) the vncpassword file for us.

By the best of my knowledge, this is the correct way to do this, although I can imagine there are better ways. Hopefully QNAP changes this in the future to something we can manage from Linux Station or in Ubuntu.

The file we are going to create is: /etc/systemd/user/setmyvncpassword.service

We start this by executing the following in terminal:


sudo nano /etc/systemd/user/setmyvncpassword.service

This will open nano, a pretty easy to use text editor. Feel free to use any other plain text editor like “vi” etc.
Since we execute this as administrator (sudo), you will be asked for the admin password. I found (on my QNAP anyway) that this is the same password as for the admin of my QNAP.

The content of this file:


1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=set my password for vnc
Before=x11vnc.service
[Service]
ExecStartPre=/bin/mkdir -m 0700 -p /tmp/.qnap
ExecStartPre=/bin/bash -c "echo MYPASSWORD > /tmp/.qnap/vncpassword"
ExecStart=/bin/true
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

Note that you’d want to change “MYPASSWORD” to your own password of course.
You should probably not use the same password as the one you use for the login on your QNAP.

OK, if you worked with nano, then close it by pressing CTRL+X, answer the question by pressing the “Y” key, and press ENTER for the filename.

The next steps are to make sure this new “service” is being activated, and actually will fire at boot time;


sudo systemctl enable /etc/systemd/user/setmyvncpassword.service

Again, this may require you to enter the sudo password again.

Now it’s time to restart Linux Station. I tried the command-line approach (shutdown -r now) but that comes with strange results.
Instead I found clicking the “Restart” button in Linux Station to work just as well.

Once you have restarted Linux Station, verify that the file /tmp/.qnap/vncpassword indeed holds your password as content.

If all went well, you should now always be able to get into your Linux Station, straight from VNC without the need to login to your QNAP.

Black Screen with VNC 

Since one of the recent updates of QTS, VNC turns or starts black when you have used the web-interface to access Ubuntu. By using the web-interface, the screen gets blanked (no matter what you try, and you cannot “wake up” the screen either).

To avoid or fix this:
1) Disable Ubuntu (in Linux Station).
2) Enable Ubuntu (in Linux Station).
3) Make sure “Enable Remote Desktop” is checked.
4) Start your VNC Viewer.

DO NOT click the link show behind “Please use the following URL“.
If you do, the screen will get blanked again – follow the 4 steps above again to disable this “feature”.

 

Donation options


Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.

Comments


There are 30 comments. You can read them below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

  • Jan 26, 2018 - 2:37 AM - Piotr Comment Link

    Thank you, finally real and simple solution!!

    Reply

    Piotr

    • Feb 16, 2018 - 10:18 AM - hans - Author: Comment Link

      Awesome! Glad it worked for you as well.
      I hope QNAP will implement this in their web interface soon though … 

      Reply

      hans

  • Feb 28, 2018 - 9:56 AM - Joe Comment Link

    Hi thanks for this tuto.

    I can’t tested yet because the option remote connection is grey so I can’t enable it …

    Did you know why ? I succeed the first time and I was disconnect because a timeout. So then when I connect again the option was disable and impossible to enable it again.

    Thank you

    Reply

    Joe

    • Mar 3, 2018 - 5:28 AM - hans - Author: Comment Link

      Hi Joe,

      mine remains grey in the first few second when opening the page in the QNAP web interface.
      If the “virtual” machine is not running it will remain grey as well. In that case you will have to click “enable” or “restart” and wait a few seconds.

      Hope this helps.

      Reply

      hans

  • May 13, 2018 - 1:38 PM - Andy Comment Link

    Maybe an odd question – but how do you access the terminal if you can’t login to start with. Have I missed a step?

    Thanks

    Reply

    Andy

    • May 14, 2018 - 5:23 AM - hans - Author: Comment Link

      Hi Andy,

      not really an odd question – good catch! 

      In figure 1 you’ll see a link in the lower right corner, which would open remote access through your webbrowser. This is where you can then open terminal and do the changes.
      just below the figure I wrote “When working in Linux Station, whichever Ubuntu version, open a Terminal window and execute the following”, but I admit this could have been made a little more clear. I’ll update the text right away! 

      Thanks!

      Reply

      hans

  • May 26, 2018 - 4:18 AM - Andrea Comment Link

    Hi,

    my Linux Station has a weird behavior: I am able to access it through a VNC client but i am able to see the desktop if and only if the Remote Desktop Webpage is open, otherwise the VNC clients connects but shows just a black window. Do you have any clue on what could cause this behavior?

    Thanks!

    Reply

    Andrea

    • May 27, 2018 - 9:13 AM - hans - Author: Comment Link

      Hi Andrea,

      I have not encountered this “effect” yet and honestly would not know what would cause this – unless your VNC client is not passing keyboard and mouse signals.
      Maybe give another VNC client a try?

      Reply

      hans

    • Jun 28, 2018 - 10:12 AM - hans - Author: Comment Link

      OK, I just updated my QTS and I now have the same weird effect. 
      Looking into it and even started a conversation with QNAP about this issue.

      Reply

      hans

    • Jun 28, 2018 - 10:35 AM - hans - Author: Comment Link

      OK, so I did some playing with all the settings and I seem to have to working, following these steps, of which I’m not sure if all of them are required.

      One time: Disable screen locking / screen saver in Ubuntu. (In Ubuntu: System Settings – Brightness & Lock: set “Turn screen off when inactive for” to “Never”, and make sure “Lock” is set to “OFF”).

      After that, I closed the browser window that is showing the Ubuntu desktop, disabled “Remote desktop” en re-enabled it again in “Linux Station”. After that I restarted Ubuntu in Linux Station, but DO NOT click the link provided in the “Linux Station” window in your QNAP user interface.
      Instead I open my VNC viewer right away and things seem to be working. No more black screen.

      I tested this a few times, and for now my procedure is:

      Start my VNC viewer right away and assume Ubuntu is running in Linux Station.

      If this fails: open Linux Station and make sure I see “Status : Enabled” (right under the Ubuntu logo, above the “Disable – Restart – Reinstall” buttons).

      If status is “Status : Enabled” but you still do not get connected (verify IP address) click “Restart“.
      If status is “Status : Disabled” click “Enable“.

      In both cases give it a few seconds to give it a chance to boot Ubuntu.

      I have repeatedly tested this and it seem to be working reliable for me. Hope it works for you as well.

      Reply

      hans

  • Jul 21, 2018 - 11:49 PM - mankann Comment Link

    Thank you for this excellent, helpful and well written guide! 

    Reply

    mankann

    • Jul 30, 2018 - 4:46 AM - hans - Author: Comment Link

      Thank you Mankann for taking the time to post a thank-you note!
      Very motivating! 

      Reply

      hans

  • Jul 27, 2018 - 6:04 AM - Kamal Singh Comment Link

    Hi After following the above step I can see the password of my choice is stored but i still get the error of password incorrect when i try connecting through VNC client, please help. My qnap is tvs 1282.

    Reply

    Kamal Singh

    • Jul 30, 2018 - 5:01 AM - hans - Author: Comment Link

      Hi Kamal,

      did you try these steps?
      For some reason the webbased-VNC screws up the connection, so you’d want to avoid that.
      For the record; I just updated to QTS 4.3.4.0644 and my Linux Station stopped working all together, even re-installing doesn’t seem to work.

      Reply

      hans

      • Jul 30, 2018 - 12:28 PM - Kamal Singh Comment Link

        Hi Hans, 

        Yes i tried all the steps but couldn’t get vnc client connection. The password seems to be changed of my choice but it is not acceptable to vm on Linux station. 

        I hadfew ussues on installing Linux station on ssd so. I installed it on capacity drive first then moved it to ssds. I wanted it to run from ssds dor obvious speed reasons. 

        Reply

        Kamal Singh

        • Aug 8, 2018 - 6:26 AM - hans - Author: Comment Link

          I do not have a cooky cut answer for you, except for going through the steps agin.
          Unfortunately with the lastest Linux Station update, my Ubuntu non longer starts, so I created a VM instead.

          I would recommend reporting this to QNAP Support – it is ridiculous that they have not solved this issue yet or provided an easier way to work with this.

          Reply

          hans

  • Dec 17, 2018 - 8:56 AM - Billy Comment Link

    Hellow, I’ve following your guide line, 

    But there were some service error. it’s cause from Linux version.  I can’t enable setmypassword.service. 

    Output like

     sudo systemctl --root=/ enable /etc/systemd/user/setmyvncpassword.service
    The unit files have no [Install] section. They are not meant to be enabled
    using systemctl.
    Possible reasons for having this kind of units are:
    1) A unit may be statically enabled by being symlinked from another unit's
       .wants/ or .requires/ directory.
    2) A unit's purpose may be to act as a helper for some other unit which has
       a requirement dependency on it.
    3) A unit may be started when needed via activation (socket, path, timer,
       D-Bus, udev, scripted systemctl call, ...).

     

    Reply

    Billy

    • Dec 19, 2018 - 9:55 AM - hans - Author: Comment Link

      Hi Billy,

      I’m nowhere near my QNAP, so I cannot verify what you’re running into.
      In the meanwhile I even gave up using Linux Station, as it became unstable after one of the recent QTS updates (instead I use a Docker for the specific application I’m using).

      I’ll be able to access my QNAP in about a month (I’m traveling), but I can imagine this to be a long wait.
      Alternatively; You can submit a support ticket with QNAP (and refuse remote access by them), maybe they changed something, requiring a new trick or (hopefully) they added setting a VNC password as a standard feature now.

      I’m sorry I could not be of more help … 

      Reply

      hans

      • Dec 19, 2018 - 10:36 PM - Billy Comment Link

        I will try Docker as your recommendation, even I’ve never tried before 

        TThank you for your comment,  

        Reply

        Billy

        • Dec 20, 2018 - 9:52 AM - hans - Author: Comment Link

          You’re welcome Billy!

          As a side note:
          Docker (in my case anyway) seem to be often used for so called headless-setups (ie. there is no regular “screen”, instead there is often a web-interface). I’m definitely not an expert on Docker, it took me quite a bit of reading and testing before I got things working the way I want it. But … I have to admit that once it worked, I’ve been very satisfied with it.

          Reply

          hans

  • Jan 18, 2019 - 9:55 PM - Hussain Comment Link

    Thanks..

    Easy to follow ..

    Finally I find a solution .

    Reply

    Hussain

  • May 9, 2019 - 6:15 AM - Klaus Comment Link

    Thanks for your instructions. I still didn’t try them because I found no way to get access with different VNC software with the temporally password. I followed all your instructions and get rid of the black screen, but never pass the login screen. In the moment I try to login after have introduced the (admin) password my VNC crashes without any error. 

    I accessed with ssh the syslog and found the following entries:

    May  9 13:06:14 ubuntu_1804 systemd[1]: Started QNAP X event monitor.
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: Got Exception during getting display object.
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: Traceback (most recent call last):
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: File "/usr/bin/qnap-x.py", line 23, in run
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: self.d = Display()
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 89, in __init__
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: self.display = _BaseDisplay(display)
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: File "/usr/lib/python2.7/dist-packages/Xlib/display.py", line 71, in __init__
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: protocol_display.Display.__init__(self, *args, **keys)
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: File "/usr/lib/python2.7/dist-packages/Xlib/protocol/display.py", line 167, in __init__
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: raise error.DisplayConnectionError(self.display_name, r.reason)
    May 9 13:06:14 ubuntu_1804 qnap-x.py[8476]: DisplayConnectionError: Can't connect to display ":0": No protocol specified
    May 9 13:06:14 ubuntu_1804 systemd[1]: qnap-x.service: Main process exited, code=exited, status=1/FAILURE
    May 9 13:06:14 ubuntu_1804 systemd[1]: qnap-x.service: Failed with result 'exit-code'.
    May 9 13:06:19 ubuntu_1804 systemd[1]: qnap-x.service: Service hold-off time over, scheduling restart.
    May 9 13:06:19 ubuntu_1804 systemd[1]: qnap-x.service: Scheduled restart job, restart counter is at 286.
    May 9 13:06:19 ubuntu_1804 systemd[1]: Stopped QNAP X event monitor.

    I’m no expert, so I’m unable to find a solution. Perhaps anyone could help.

    Thanks in advance.

    Reply

    Klaus

    • May 9, 2019 - 9:46 AM - hans - Author: Comment Link

      Hi Klaus,

      I haven’t used this method in a while, since Linux Station proved quite unstable with all the updates that have come by.

      Anyhoo … back to your question ..

      The error seems to be an issue on the QNAP end. The QNAP VNC server fails to connect to X-Windows display 0 since there is no protocol defined (?).
      I honestly have no idea what to think of that, besides the “… this is why I no longer use Linux Station”. And such a statement is obviously not helpful.

      I did some searching and honestly couldn’t find anything better than this post at StackExchange. It may not be very useful either.

      What is the connection string you’re using to connect? Something like 192.168.1.100:0 (IP NAS = 192.168.1.100, Display = 0)?

      Reply

      hans

      • May 9, 2019 - 11:36 AM - Klaus Comment Link

        Hi Hans:

        Thank you for your reply. 

        I didn’t introduce the display (suppose the default is 0), but just I retried with display 1 with the same result.

        You are right, Linux Station is really unstable. Every second or third try I get “Host is temporally unavailable” or from my NAS

        App Name: Linux Station
        Category: General Operations
        Message: [Linux Station] Failed to enable remote desktop connection. Linux system: Ubuntu 18.04.

        I’m loosing patience. Did you do it with Virtualization Station or what is your solution?

        Reply

        Klaus

      • May 9, 2019 - 12:03 PM - hans - Author: Comment Link

        Hi Klaus!

        Yep, that is exactly the way I experienced it. Uninstall and reinstall made things even worse.
        It’s kinda weird though, when I wrote this article, it was very stable … until I did a QTS update a few months later, and things went downhill from there.
        After several conversations with QNAP support, I just gave up …

        I ended up using a Docker in “Container Station”. It took quite some effort to get it going, and I’m still in the dark about a few things .
        Key is that with a Docker, you’re basically relying on a web interface. So it will not be good for all purposes.
        I just wanted to have an instance of KODI running that updates my MySQL database, and for that it has been very solid.
        It even allows playback of video in your browser (if your QNAP can keep up).

        Note : I did not get KODI to run in “Virtualization Station” because of its graphical/GPU requirements (using Librelec).
        Otherwise everything seems to run just fine (but it seems a little bit slower than the old “Linux Station”).

        Reply

        hans

        • May 9, 2019 - 1:13 PM - Klaus Comment Link

          Hi Hans,

          I tried to get working a container with Calibre and had a lot of difficulties to find out how to configure it. Some things didn’t do what they should and later Container Station GUI stopped working. So I tried to find another way to manage containers. Soon noticed that this is not a simple task and so I thought it would be easier to do it with Linux Station. Now I’m stuck with Linux Station.

          I got working a clone of my Virtual Box Windows 10 in Virtualization Station – loosing my activation because I found no way to change the UID of the clone. A new Win10 pro license (34€) did it. I access it without any difficulties by RDP from my Linux box.

          Just had a look what OS’s are available in VB and found out that Ubuntu 18.04 LTS is not available. It seams Qnap will not make it available and announced Linux Station with Ubuntu 18.04 instead.

          Its a pitty and I’m sorry having bought my NAS at Qnap. Now its done and I should find solutions.

          Reply

          Klaus

        • May 10, 2019 - 3:17 AM - hans - Author: Comment Link

          Hi Klaus,

          first off, don’t be disappointed too much in QNAP. I have had a few other brands and so far QNAP has proven to be the most reliable.
          It is sad that Linux Station is not working well, but I always try to keep in mind that it’s a NAS and not full size server for virtual machines .

          Having said that; they should have done a better job with the virtualization features. Either offer them working well, or do not offer it.
          I think Linux Station’s approach is pretty good – it uses the underlying Linux from the QNAP, which makes it faster than a virtual machine.
          Just some of the choices they’ve made are not all that good.
          I mean, let’s be real; nice that you can work with it (if it works) in a web browser, but I’d really prefer using VNC or something like that.

          I just took a look at the QNAP forum and, as expected, other users are experiencing similar issues.

          I’m not familiar with Calibre, but it seems there is a Docker available for that, see linuxserver.io. I recommend giving it a try.
          QNAP has an intro to Docker, but you may need to find some more info. Amore generic (and sometimes confusing) guide can be found here.
          Like I said; I’m running a headless KODI like this and am very impressed by its speed and stability.

          p.s. since I run Windows 10 Pro as a virtual machine on my Mac, I too had to buy an extra license. I hate the way Microsoft handles licenses, and it looks like you found a similar address for affordable Windows licenses (I’ve had great experiences with Kinguin.net, Win10Pro for €26).

          Reply

          hans

  • May 10, 2019 - 9:52 AM - Klaus Comment Link

    Thanks, Hans, I have just created a ticket. If you’re interested I will inform you.

    Regards, Klaus

    Reply

    Klaus

    • May 10, 2019 - 12:49 PM - hans - Author: Comment Link

      Thanks Klaus!

      Yes please do so! I’d be interested in getting Linux Station to work properly again as well.

      Tip:
      They typically ask you for access to your QNAP.
      I personally really do not like that, so after a bit of asking, the support person finally told me the steps so I can fix things myself. 

      Reply

      hans



Your Comment …

Friendly request to not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.
Tweaking4All will never share your email address with others.