3

I have a vps which has the basic xfce environment & tightvncserver installed.

I would like to have tightvncserver automatically start whenever I initiate a connection to the port it runs on (in my case, 5901).

I've seen posts about using inetd or xinetd to do this, but I've also seen lots of posts saying that (x)inetd is not included in Ubuntu for a reason, and that it's a bad idea to use it.

Anyways, I'm looking for a way to auto-start tightvncserver whenever there's an incoming connection to port 5901, preferably with as few dependencies as possible

1
  • In general using inetd or xinetd is indeed a bad idea, but that's like saying that in general it is a bad idea to use a nail gun. Yet for certain jobs, it's the right tool. The main issue is performance. Launching a new process for every connection is an extremely slow process. Aug 19, 2020 at 19:01

2 Answers 2

1

I don't know why is "bad idea using xinetd or inetd". I checked both bug tracker and didn't saw any security issue.

That said, I will try to repeat what you already have found about configuring 'xinetd':

xinetd is pretty straight forward to configure. It uses the /etc/xinetd.d/ directory to store all the per-service configuration, so you only need to create the configuration to start tightvncserver, a sudo vim /etc/xinetd.d/tightvncserver to create a file, then insert your configuration (this can be modified according to your needs):

service tightvncserver
{
        socket_type     =  stream
        protocol        =  tcp
        wait            =  no
        ## I don't run a vnc server myself, but you should change this for the user your VNC service uses.
        user            =  root
        port            =  5901
        server          =  /usr/sbin/tightvncserver
        ## This allows access from anyone in the 192.168 subnet, if you want anyone, just do not add this line.
        only_from       =  192.168.0.0
        log_on_failure  += USERID
        disable         =  no
}

That's all. Now you should disable boot up of the tightvncserver in the rc-d directories.

There are more options you can add to this, but I shall leave that to the manual.

6
  • That's quite helpful if I decide to go the xinetd route. I just stumbled across the built-in xinetd replacement the Ubuntu ships with, Upstart. I'm going to see if I can get the desired functionality from Upstart's socket events.
    – QRohlf
    Aug 8, 2013 at 20:08
  • Also, here is an example of the kind of negativity towards (x)inetd I've been seeing on this site and the Ubuntu forums. Not sure if it's warranted or not, but there are definitely a number of people who don't think it's a good idea to use (x)inetd.
    – QRohlf
    Aug 8, 2013 at 20:11
  • @QRohlf he just says to avoid inetd not xinetd: "you should avoid using inet at all"
    – Braiam
    Aug 8, 2013 at 20:14
  • Ah. That makes a lot more sense - the other two places I saw inetd being knocked, it was inetd and not xinetd as well. Thanks for clearing that up!
    – QRohlf
    Aug 8, 2013 at 21:29
  • Despite finding basically this exact same recipe in 4 or 5 other places on the Internet, it doesn't work at all for me. tightvncserver just hangs when a client connects.
    – Glyph
    May 28, 2014 at 8:22
0

Rather than try and use tightvncserver I would attempt to the same thing that @Braiam's suggested but with Xvnc instead.

service Xvnc
{
        disable = no
        type = UNLISTED
        socket_type = stream
        protocol = tcp
        user = nobody
        wait = yes
        server = /usr/bin/Xvnc
        server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -NeverShared -once -rfbauth /root/.vncpasswd
        port = 5901
}

You can adjust where the password file lives by changing this bit above: /root/.vncpasswd. The permissions on that file can be squirrelly so you might need to make them chmod 600 .vncpasswd.

If you need further details take a look at the tutorial, 2. Launching VNC server using xinetd that shows many different ways that you can run VNC as a xinetd service.

Using xinetd

The entire commentary on not using xinetd is bunk. It's a perfectly fine service to use and just as everything else, you need to understand the implications of using technology X, nothing more.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .