LAN only VNC setup
Method #1 - VNC from ComputerA -> B
where a user is already logged in on B
You don't specify what VNC client you're using but one of the more popular ones is Vinagre. It's typically included with GNOME desktop based distros, which should cover most of the larger distros.
Installation
First you'll want to make sure that you have GNOME's VNC client, vinagre
installed as well as the VNC server, vino
.
On my Fedora 19 system these packages required installation.
$ sudo yum install vinagre vino
On Ubuntu you'd install the same packages, using apt
.
$ sudo apt-get install vinagre vino
Server setup
Once installed you'll want to make sure that the VNC server is running on computer B. You can do this either by navigating through Settings -> Sharing menu from where you can select to enable "Screen Sharing".
Fedora
Ubuntu
NOTE: You can invoke vino's preferences from the command line like so:
$ vino-preferences
Client setup
Once the VNC server's been setup on computer B, you should now be able to connect to it from computer A, using vinagre
, the VNC client. You can do this either from the command line like so:
$ vinagre vnc://greeneggs.bubba.net
Where the vnc://...
is the server string provided by vino
, as in the screenshot above.
Additional notes
- If you need to summon the VNC server's dialog directly from the command line it's called
vino-preferences
. -
vinagre
is also a GUI that can be launched bare, and bookmarks can be maintained for VNC severs that you may frequent.To launch it use the commandvinagre
.
Method #2 - VNC from ComputerA -> B
where a user is not already logged in on B
Server setup
Ubuntu
-
Install
x11vnc
$ sudo apt-get install x11vnc
-
Create
/etc/init/x11vnc.conf
file.start on login-session-start script x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -o /var/log/x11vnc.log end script
After restarting (rebooting),
x11vnc
should be listening on the standard VNC port, 5900.-
You can confirm
$ sudo netstat -tapn | grep 5900 tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 2379/x11vnc tcp6 0 0 :::5900 :::* LISTEN 2379/x11vnc
NOTE: The script is based on an upstart event mechanism where Lightdm emits login-session-start
events, x11vnc
is then started.
References
Related videos on Youtube
oshirowanen
Updated on September 18, 2022Comments
-
oshirowanen almost 2 years
GOAL:
I have 2 computers in a LAN environment (I will refer to them as [computer A] and [computer B]) and I want to log into [computer B] via [computer A].
I have a VNC client on [computer A]
Remote Desktop Viewer
and I have setupDesktop Sharing Preferences
on [computer B], see screenshots below. The LAN IP address of [computer A] is 192.168.0.1 and the LAN IP address of [computer B] is 192.168.0.2.Both computers have no problem pinging to each other!
QUESTION:
My question is, how do I connect to [computer B] from [computer A]?
ERROR MESSAGE:
I am currently getting the following error message when I try to connect:
connection to 192.168.0.2 was closed
192.168.0.2 is the IP address of [computer B].
PORTS / FIREWALL:
I can't see the port 5900 listed when I run
sudo lsof -i -P | grep -i listen
. I don't have a firewall installed either. I've now installed Gufw on both [computer A] and [computer B]. I am not sure how to configure it. Do I set it up to allow incoming connections for vnc on [computer B] and allow outgoing connections for vnc on [computer A]?
OTHER INFO:
Computer A = 192.168.0.1 = Ubuntu 12.04 Computer B = 192.168.0.2 = Debian Stable
Both are fully updated
IPTABLES (same on server and client):
Chain INPUT (policy ACCEPT) target - prot opt source - destination Chain FORWARD (policy ACCEPT) target - prot opt source - destination Chain OUTPUT (policy ACCEPT) target - prot opt source - destination
LISTENING PORTS
sudo lsof -i -P | grep -i listen rpcbind 1853 root 8u IPv4 5755 0t0 TCP *:111 (LISTEN) rpcbind 1853 root 11u IPv6 5762 0t0 TCP *:111 (LISTEN) rpc.statd 1884 statd 8u IPv4 5818 0t0 TCP *:56428 (LISTEN) rpc.statd 1884 statd 10u IPv6 5826 0t0 TCP *:39576 (LISTEN) cupsd 2615 root 6u IPv6 17952 0t0 TCP localhost:631 (LISTEN) cupsd 2615 root 8u IPv4 17953 0t0 TCP localhost:631 (LISTEN) mysqld 3042 mysql 10u IPv4 7466 0t0 TCP localhost:3306 (LISTEN) exim4 3855 Debian-exim 3u IPv4 8075 0t0 TCP localhost:25 (LISTEN)
SCREENSHOTS:
This is the client software I have on [computer A]:
This is the software (server software I guess) I have on [computer B]:
-
user80551 over 10 yearsDid you enable incoming connections in the firewall for computer B. You can do it using gufw
-
oshirowanen over 10 yearsI had to install and enable gufw to do that and it made no difference.
-
Elliott Frisch over 10 yearsHave you verified you can telnet to port "5900" on the server from the client?
-
oshirowanen over 10 years@ElliottFrisch, I can't telnet to 5900 to the server from the client. I get
Unable to connectto remote host: Connection refused
. -
Elliott Frisch over 10 years@oshirowanen Then the server isn't allowing remote connections; do you have any "ipfw" rules? Also, you might consider trying PortForwarding.
-
oshirowanen over 10 yearsI've not touched the iptables at all, so whatever the default settings are on Debian is what my current iptables is set to on the server. I'll update the question with the output I get from the servers iptables in a moment.
-
oshirowanen over 10 years@ElliottFrisch, done.
-
Elliott Frisch over 10 years@oshirowanen which vnc server package did you install?
-
oshirowanen over 10 years@ElliottFrisch, vnc server is vino and vnc client is vinagre.
-
Elliott Frisch over 10 yearsAnd you're logged in to the server and you've started vino-server?
-
-
oshirowanen over 10 yearsSo I need to install vinagre on computer A and vino on computer B?
-
oshirowanen over 10 yearsI've installed vinagre on computer A and vino on computer B. I then laungh vino-preferences and it looks totally different from your screenshot. On my computer, it has the title Desktop Sharing Preferences and it doesn't display a vnc type link/path. Anyway, I tried to continue and tried connecting to the server, but it can't connect.
connection to 192.168.0.2 was closed
. -
oshirowanen over 10 yearsI can't see the port 5900 listed when I run that command. I don't have a firewall installed either. I've now installed Gufw on both [computer A] and [computer B]. I am not sure how to configure it. Do I set it up to allow incoming connections for vnc on [computer B] and allow outgoing connections for vnc on [computer A]?
-
Ben Lin over 10 yearsIf you don't have port 5900 opened for listening in [Computer B], that is not a good sign. sounds like the VNC server (desktop sharing server) is not running well in this server. Please give out the result of the command
sudo lsof -i -P | grep -i listen
It's better if you DON'T have firewall :) -
slm over 10 years@oshirowanen - what happens when you run this command from computerA?
telnet 192.168.0.2 5900
? If this doesn't work then you have 1 of 2 problems. Routing b/w A & B isn't correct, or the VNC server on B isn't running or accepting connections on port 5900. Also when replying to me do an at sign@
+ slm, otherwise I won't see your comments. I hadn't see the above ones until today, just by accident. -
oshirowanen over 10 yearsYes, when I try to VNC from A -> B, I login as a user on B.
-
slm over 10 years@oshirowanen - OK, that's b/c it's my A, so those do get through. Oddly I do not remember seeing any comments from this on Dec 28th, no matter. The telnet is telling you that there is no VNC server running on computer B!
-
slm over 10 years@oshirowanen - what I mean when I say "logged in already" is that userX is already logged into computer B and you're running VNC client from computer B, logging in as userX. The method discussed with
vino
requires the user is already logged into the desktop on computer B. -
oshirowanen over 10 yearsBut I installed vino and set it as shown in my screenshot, which seems to mirror your screenshot?
-
slm over 10 years@oshirowanen - and you're logged into B, can you check the box to always show the vnc icon in the tool bar?
-
oshirowanen over 10 yearsDone, but I can't see a vnc icon in the notification area.
-
oshirowanen over 10 years
what I mean when I say "logged in already" is that userX is already logged into computer B and you're running VNC client from computer A, logging in as userX
, or did you really meanwhat I mean when I say "logged in already" is that userX is already logged into computer B and you're running VNC client from computer B, logging in as userX
? -
slm over 10 yearsNo what I said is what I meant. It's confusing but you can only establish a connection using VNC if the user you're logging in as, is already logged in on computer B. This is b/c vino will not run until userX has logged into the desktop.
-
oshirowanen over 10 yearsSo that means I need to use your
Method 2
? But I think I need to get the server listening to port 5900 first? Or does Method 2 correct that problem too? I've updated my question to include further port details, I see port 5900 nowhere... -
slm over 10 yearsMethod #2 will take care of starting the server. A reboot is required. Only 1 time to trigger the starting of X11Vnc as part of the starting of lightdm (Ubutnu's login manager).
-
oshirowanen over 10 yearsThanks, I'll try that and get back to you as soon as possible.
-
slm over 10 years@oshirowanen - take your time and good luck. I'll be here if you need help and/or have questions.
-
oshirowanen over 10 yearsThanks! Got another question (already). My server is a Debian server and I have XFCE installed with GDM as the display manager. Your method 2 instructions are based on Ubuntu. I'm assuming those instructions are to be executed on the server and not on the client? Just wanted to make sure because with me having Ubuntu as the client and your instructions being based on Ubuntu, it's getting confusing. I've sure those instructions are for the server, but as I have GDM instead of lightdm, that .conf file probably needs to be a little different?
-
slm over 10 yearsYes the directions for the setup are meant for the servers. Given you're using Debian your directions will be slightly different (I would expect) though I do not have access to Debian to confirm this for a fact. So you're going to have to experiment. I'll try and get a Debian system setup if possible.
-
slm over 10 years@oshirowanen - this thread might be of help: forums.debian.net/viewtopic.php?f=5&t=55327. Also running x11vnc manually on computer B will likely prove this approach is correct. Making it part of computer B's startup can be dealt with afterwards. Also this URL might be helpful: wiki.archlinux.org/index.php/X11vnc