LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   tightvnc - vncserver at startup? (https://www.linuxquestions.org/questions/linux-networking-3/tightvnc-vncserver-at-startup-743457/)

petersk 07-28-2009 12:50 PM

tightvnc - vncserver at startup?
 
I'm running a linux host that I'd like to be able to log in using vnc. I cannot find any instructions the show how to log in remotely without either:
1) having a session already started on the host machine or
2) logging in through port forwarding using ssh.

Is it possible to have a vncserver start at boot and accept incoming connections for users without using either of the above two methods?

Regards,
Kurt

tredegar 07-28-2009 01:15 PM

Quote:

Is it possible to have a vncserver start at boot and accept incoming connections for users without using either of the above two methods?
Of course ;)
See here

Rather than using vnc, you might like to take a look at nx

jschiwal 07-28-2009 05:43 PM

If this is on a lan and security isn't an issue, you could use xdcmp logins. If over the internet, you could use a VPN tunnel.

petersk 07-29-2009 08:41 AM

Thanks for the info,
If I use:
su - tred -c " cd /home/tred && vncserver :1 -geometry 1024x768 -depth 24"
1. is there a way to tell if it's running, and
2. is there a way to tell which port it is using?

Regards,
kurt

petersk 07-29-2009 08:43 AM

Can nx leave a session open that I can reconnect to at a later time?

geek745 07-29-2009 09:14 AM

Quote:

1. is there a way to tell if it's running, and
2. is there a way to tell which port it is using?
you should be able to tell if it's running by connecting to it as you plan to. VNC uses TCP port 5900 unless you have configured it otherwise. You can also check the process table for it with
Code:

ps ax | grep vncserver
and you can check connections to it with
Code:

netstat -nt | grep 5900

tredegar 07-29-2009 10:22 AM

Quote:

Can nx leave a session open that I can reconnect to at a later time?
I expect so, I haven't used nx yet (too lazy to install it when vnc is working) but it has repeatedly been recommended as "better" than vnc.

Possibly the best thing for you to do is stop asking hypothetical questions and worrying, and just install either vnc or nx or both.

petersk 07-29-2009 10:24 AM

I was able to ps aux | grep vnc to see it was running.

I also had to set up a password using vncpasswd.

Finally, I figured out that it was on port 5901 using the log file in my .vnc directory.

I

Unfortunately, despite adding startkde & to my xstartup, I just get a gray screen. I tried a local log in, and that shows a gray screen as well (vncviewer localhost:1). Any advice on what I might be doing wrong? Here's the output of my xstartup in .vnc:
Code:

$ cat .vnc/xstartup

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
#/etc/X11/Xsession
startkde &

Kurt

tredegar 07-29-2009 10:34 AM

Quote:

Finally, I figured out that it was on port 5901 using the log file in my .vnc directory.
Well done. Screen:0 is on port 5900 screen:1 is on 5901 etc (these are the defaults)
Quote:

Unfortunately, despite adding startkde & to my xstartup, I just get a gray screen.
That file looks OK to me, but do you realise that it needs to be on the host, not your local machine? Check the xtartup file on the pc you want to be able to access.

petersk 07-29-2009 10:36 AM

Yes, that's on the remote machine. Should Xsession be commented out -- it seemed to make no difference between commenting it out and not, regardless, So, I'm not sure what the problem is, although I'm using Kubuntu, and there's no /etc/vnc directory nor any /etc/vnc.conf
Kurt

tredegar 07-29-2009 10:53 AM

I'm running kubuntu (6.06 and 8.04)
On server:
Code:

tgar@server:~$ which vncviewer
/usr/bin/vncserver
tgar@server:~$ ls -l /usr/bin/vncserver
lrwxrwxrwx 1 root root 27 2006-11-06 16:05 /usr/bin/vncserver -> /etc/alternatives/vncserver
tgar@server:~$ ls -l /etc/alternatives/vncserver
lrwxrwxrwx 1 root root 23 2006-11-06 16:05 /etc/alternatives/vncserver -> /usr/bin/tightvncserver
tgar@server:~$

See what is happening?
There are several vnc's, and you can have them all installed, but the one which is used when you just call vncserver is the one pointed to in /etc/alternatives, in my case /usr/bin/tightvncserver

I have the following packages installed on server:
tightvncserver
vnc-common
xtightvncviewer


It works well.

Maybe you are using different packages ?

tredegar 07-29-2009 10:58 AM

A follow-up: don't forget to "kill" any extra vncservers before you start new ones, or you'll have no idea of what ports they are working on, and you may find yourself looking at a "bad" screen (maybe setup with an old config) when the "good" one is running well on the next port up.
Hope this makes sense.

petersk 07-29-2009 11:32 AM

Thanks, but I've been doing a reboot after each configuration change try.
Code:

$ which vncviewer
/usr/bin/vncviewer
$ ls -l /usr/bin/vncserver
lrwxrwxrwx 1 root root 27 2009-07-28 11:23 /usr/bin/vncserver -> /etc/alternatives/vncserver
$ ls -lat /etc/alternatives/vncserver
lrwxrwxrwx 1 root root 23 2009-07-28 11:23 /etc/alternatives/vncserver -> /usr/bin/tightvncserver
$ ls -l /usr/bin/vncserver
lrwxrwxrwx 1 root root 27 2009-07-28 11:23 /usr/bin/vncserver -> /etc/alternatives/vncserver

Seems my configuration is the same as yours.
Kurt

tredegar 07-29-2009 11:52 AM

I don't know what is happening here.

On your local PC try starting a vncserver and connecting to it locally. For me, it goes like this:
Code:

tred@vaio:~$ vncserver :1 -geometry 800x600 -depth 24

New 'vaio:1 (tred)' desktop is vaio:1

Starting applications specified in /home/tred/.vnc/xstartup
Log file is /home/tred/.vnc/vaio:1.log
tred@vaio:~$ vncviewer localhost:1
VNC Viewer Free Edition 4.1.1 for X - built Apr 16 2008 13:02:40
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.

Wed Jul 29 17:46:36 2009
 CConn:      connected to host localhost port 5901
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8

Wed Jul 29 17:46:41 2009
 TXImage:    Using default colormap and visual, TrueColor, depth 24.
 CConn:      Using pixel format depth 6 (8bpp) rgb222
 CConn:      Using ZRLE encoding
 CConn:      Throughput 20000 kbit/s - changing to hextile encoding
 CConn:      Throughput 20000 kbit/s - changing to full colour
 CConn:      Using pixel format depth 24 (32bpp) little-endian rgb888
 CConn:      Using hextile encoding

Does it work?
if not, please post your local ~/.vnc/xstartup and take a look at the log.
My xstartup just says
Code:

#!/bin/sh
startkde &

.. and please make sure xstartup has executable permissions.

No need to reboot (slow and boring):
Code:

tred@vaio:~/.vnc$ ps -Al | grep vnc
0 S  1005 14279    1  0  80  0 -  3380 -      pts/1    00:00:01 Xvnc
tred@vaio:~/.vnc$ kill 14279
tred@vaio:~/.vnc$


petersk 07-29-2009 12:02 PM

I tried changing my xstartup to just contain startkde &.

Code:



~/.vnc$ vncserver -kill :1
Killing Xtightvnc process ID 4268           
~/.vnc$ ps aux | grep vnc
  4344  0.0  0.0  3336  792 pts/1    R+  11:06  0:00 grep vnc
~/.vnc$ vncserver :1 -geometry 800x600 -depth 24

New 'X' desktop is E53A-EDA-DB:1

Starting applications specified in /home/kpeters/.vnc/xstartup
Log file is .vnc/E53A-EDA-DB:1.log

~/.vnc$ vncviewer localhost:1

VNC Viewer Free Edition 4.1.1 for X - built Apr 16 2008 13:02:40
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.

Wed Jul 29 11:07:08 2009
 CConn:      connected to host localhost port 5901
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8

Wed Jul 29 11:07:12 2009
 TXImage:    Using default colormap and visual, TrueColor, depth 24.
 CConn:      Using pixel format depth 6 (8bpp) rgb222
 CConn:      Using ZRLE encoding
 CConn:      Throughput 20010 kbit/s - changing to hextile encoding
 CConn:      Throughput 20010 kbit/s - changing to full colour
 CConn:      Using pixel format depth 24 (32bpp) little-endian rgb888
 CConn:      Using hextile encoding

still a grey screen.. :-(

Code:

-rw-r--r--  1 kpeters kpeters 2814 2009-07-29 11:10 E53A-EDA-DB:1.log
drwxr-xr-x 51 kpeters kpeters 4096 2009-07-29 11:07 ..
drwx------  2 kpeters kpeters 4096 2009-07-29 11:07 .
-rw-r--r--  1 kpeters kpeters    5 2009-07-29 11:07 E53A-EDA-DB:1.pid
-rwxr-xr-x  1 kpeters kpeters  22 2009-07-29 11:06 xstartup
-rwxr-xr-x  1 kpeters kpeters  336 2009-07-29 11:06 xstartup.back
-rw-------  1 kpeters kpeters    8 2009-07-29 08:13 passwd


tredegar 07-29-2009 12:26 PM

Strange.
Anything helpful in the E53A-EDA-DB:1.log file?
Mine is just called vaio:1.log
I wonder why yours is different ? Is your hostname E53A-EDA-DB ?
Horrible thought: Are you running a "virtual machine" ?

petersk 07-29-2009 02:42 PM

OK, I got the checkered/ grey / gray screen to go away and it to work by chmod +x /etc/X11/xinit/xinitrc

That allows it to work if vncserver is started "locally." But it still gives me a gray screen if I try the "startup" in rc.local.

THis is pretty confusing.
Kurt


All times are GMT -5. The time now is 12:48 AM.