Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 setup Desktop 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]: enter image description here

This is the software (server software I guess) I have on [computer B]: enter image description here

share|improve this question
    
Did you enable incoming connections in the firewall for computer B. You can do it using gufw –  user80551 Dec 30 '13 at 12:42
    
I had to install and enable gufw to do that and it made no difference. –  oshirowanen Dec 30 '13 at 18:28
    
Have you verified you can telnet to port "5900" on the server from the client? –  Elliott Frisch Jan 2 at 1:59
    
@ElliottFrisch, I can't telnet to 5900 to the server from the client. I get Unable to connectto remote host: Connection refused. –  oshirowanen Jan 2 at 18:48
1  
And you're logged in to the server and you've started vino-server? –  Elliott Frisch Jan 2 at 19:15

4 Answers 4

up vote 2 down vote accepted
+100

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

     ss of vino

Ubuntu

              ss of ubuntu prefs

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 command vinagre.

      ss of vinagre

Method #2 - VNC from ComputerA -> B

where a user is not already logged in on B

Server setup

Ubuntu

  1. Install x11vnc

    $ sudo apt-get install x11vnc
    
  2. 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
    
  3. After restarting (rebooting), x11vnc should be listening on the standard VNC port, 5900.

  4. 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

share|improve this answer
    
So I need to install vinagre on computer A and vino on computer B? –  oshirowanen Dec 28 '13 at 9:34
    
I'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 Dec 28 '13 at 10:13
    
@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. –  slm Jan 2 at 15:17
    
I tried your telnet test and I get Unable to connect to remote host: Connection refused, even though ping works fine. I tried adding an @slm to to start of this comment, but it gets stripped out? –  oshirowanen Jan 2 at 18:40
    
Yes, when I try to VNC from A -> B, I login as a user on B. –  oshirowanen Jan 2 at 18:45

It depends on your VNC client config, basically. Though almost all VNC clients work similarly, you need to give it the IP/hostname and the port used by your VNC server (which by default is 5900 and so on).

share|improve this answer

I would suspect a firewall issue. In the [Computer B], execute

sudo lsof -i -P | grep -i listen

to verify whether port 5900 is open for VNC .

share|improve this answer
    
I 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]? –  oshirowanen Dec 30 '13 at 18:11
    
If 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 :) –  Ben Lin Dec 31 '13 at 18:56

Check you VNC server configuration and makesure that the port number you give is 5900+Number of seesions for give user.. This number you would have given in the configuration page of your VNC server. If you have given the number as 2, then the port number you need to define 5902.

Try this. it might be of little help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.