Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Mon Apr 23, 2012 7:09 pm

I am still having trouble getting my monitor to work at any descent resolution with the Pi despite Dom and co's best efforts so I decided to setup VNC to remote desktop into it.

I have long been a fan of TightVNC so I decided to use that, for those interested here is what I did.

Log in to your Pi and install the Tight VNC Package

$ sudo apt-get install tightvncserver

Next Run TightVNC Server which will prompt you to enter a Password and an optional View Only Password

$ tightvncserver

Once that is done you can run it straight from the prompt I am using 1920x1080 which is my monitor maximum resolution.

$ vncserver :1 -geometry 1920x1080 -depth 24

Or you could create a script to save typing in the whole thing.

$ nano svnc.sh (call the file whatever you like and ending in .sh)

Add the line: vncserver :1 -geometry 1920x1080 -depth 24

Ctrl-x y <return> (To Exit Nano and Save)

Set the file to Execute

$ chmod +x svnc.sh

then to run

$ ./svnc.sh

ToDo: Run at boot.

Install Tight VNC on your desktop from the link below or most VNC clients work I believe.

http://www.tightvnc.com/download.php

Then use <Your Pi IP>:1 (e.g. 192.168.1.2:1) as the host name when connecting.

Works Great, select full screen from the tool bar and a full 1080p 24bit desktop is yours from anywhere.

itsonlyme
Posts: 131
Joined: Sun Feb 12, 2012 12:43 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:16 pm

Thanks for this, Simon.

"Reversing!" the procedure has enabled me to view my Windows Desktop on my Pi.

This was stage 4 of my Pi project. I am still struggling with 1,2, and 3 (but getting there slowly) while waiting for the sound to be properly sorted. It is great that a complete newbie to Linux could get this downloaded, installed, and working without even a little problem in under 10 minutes.

The benefit for me, now a bit doddery on my pins, is that while watching TV I do not need to get up from my armchair to check progress of something I have left running on my Windows PC but just switch the TV for a moment from HDMI2 to HDMI1.

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:31 pm

I have added this to the wiki http://elinux.org/RPi_Guides

If anybody would like to tidy up the text, feel free.

User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:34 pm

That's great - thanks Simon!  Just one question.  How do I VNC into the X instance that's currently running on my TV?  If I run vncserver :1.... from my Pi, then VNC in, I get a completely new instance.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:37 pm

@itsonlyme I haven't tried it the other way round, will give it a go later

Have got it to start on boot but it was late night so I will post that when I get home. @bredman Will add to the guide.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:44 pm

Tass said:


That"s great – thanks Simon!  Just one question.  How do I VNC into the X instance that"s currently running on my TV?  If I run vncserver :1…. from my Pi, then VNC in, I get a completely new instance.


:0 is your main desktop, I tried that but it wouldn't let me startx and vice versa, don't think it lets you mirror a desktop like it does in windows, when I tried it said it was locked. We run VNC on Solaris at work and it is the same, it create a whole new instance of the desktop.

Anyone else manged this in linux?

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:48 pm

Simon,

It's a bit difficult for a new user to deal with the fact that the IP address may change dynamically.

Can you check your hostname? Use the command

cat /etc/hostname

and then use the hostname instead of the IP address, for example

RaspberryPi:1

It would be good if you or somebody else could test this because I don't have a RPi available.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 12:58 pm

bredman said:


Simon,

It"s a bit difficult for a new user to deal with the fact that the IP address may change dynamically.

Can you check your hostname? Use the command

cat /etc/hostname

and then use the hostname instead of the IP address, for example

RaspberryPi:1

It would be good if you or somebody else could test this because I don"t have a RPi available.


Will look at the host name thing, should work but windows can be funny resolving hostnames sometimes if it doesn't know them.

:1 is actually 5900 + 1 (5901) :0 = 5900 when using the linux version. In tightvnc viewer it worked IP:1 but in the android version I have on my phone I had to change the port to 5901 and leave the IP as normal.

I will have another play later and update the instructions.

wob86
Posts: 8
Joined: Wed Mar 07, 2012 10:41 am
Contact: Website

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 1:19 pm

Simon H said:


Tass said:


That"s great – thanks Simon!  Just one question.  How do I VNC into the X instance that"s currently running on my TV?  If I run vncserver :1…. from my Pi, then VNC in, I get a completely new instance.


:0 is your main desktop, I tried that but it wouldn"t let me startx and vice versa, don't think it lets you mirror a desktop like it does in windows, when I tried it said it was locked. We run VNC on Solaris at work and it is the same, it create a whole new instance of the desktop.

Anyone else manged this in linux?


In work we use XRDP instead of VMC on the Linux servers, and we have managed to restore the same session by making sure the resolution is the same.  not sureif VNC is similar?  or if not XRDP is quite nice and easy to use and runs on debian.

User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 1:21 pm

wob86 said:


In work we use XRDP instead of VMC on the Linux servers, and we have managed to restore the same session by making sure the resolution is the same.  not sureif VNC is similar?  or if not XRDP is quite nice and easy to use and runs on debian.


Thanks - I'll try it out tonight & feed back.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 6:31 pm

Simon H said:


Tass said:


That"s great – thanks Simon!  Just one question.  How do I VNC into the X instance that"s currently running on my TV?  If I run vncserver :1…. from my Pi, then VNC in, I get a completely new instance.


:0 is your main desktop, I tried that but it wouldn"t let me startx and vice versa, don't think it lets you mirror a desktop like it does in windows, when I tried it said it was locked. We run VNC on Solaris at work and it is the same, it create a whole new instance of the desktop.

Anyone else manged this in linux?



I have had a search around and it seems it is not possible to mirror a desktop like windows, as I thought it creates a whole new instance.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 7:07 pm

bredman said:


Simon,

It"s a bit difficult for a new user to deal with the fact that the IP address may change dynamically.

Can you check your hostname? Use the command

cat /etc/hostname

and then use the hostname instead of the IP address, for example

RaspberryPi:1

It would be good if you or somebody else could test this because I don"t have a RPi available.



I tried using the hostname from /etc/hostname but as I thought windows cannot resolve the name.

Windows resolves hostnames either from windows announce packets that flood your network which the pi won't broadcast, the hosts file or DNS.

Some rooters might take there DHCP clients names and add them to its DNS resolution but you can't rely on that. Mine is set to use my internal servers DNS or an external one if that one isn't available.

If it is for a general home network it is better to use IP addresses. At the end of the boot the Pi tells you the Ip address it is using or if you are going to use it headless you would be better using a static IP (A whole other Howto needed).

Simon.

User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 7:51 pm

Thanks Simon.  So I suppose the idea of using a Pi as a media server to remote into & control isn't possible then.  I suppose I bluetooth mouse would work, provided I find one with decent range.  I also read something about XMBC having an Android remote client which is an option too.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 8:03 pm

Tass said:


Thanks Simon.  So I suppose the idea of using a Pi as a media server to remote into & control isn't possible then.  I suppose I bluetooth mouse would work, provided I find one with decent range.  I also read something about XMBC having an Android remote client which is an option too.



I did read you can vnc back into itself as well as remotely but that is a bit messy.

Yes the XBMC Android remote is great, I use it at home to control both an old Xbox 1 hacked with XBMC on it and my laptop connected to my TV that is the main media center. The next Pi I get will be going to replace my laptop which is noisy when playing HD video and frankly a waste sitting behind my TV. Look in other XBMC threads, there is alot of discussion about using all sorts of remote controls on it.

Openelec have already released early XBMC code which some have compiled successfully in another thread, will be having a go myself when I get a spare hour or 2.

User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 8:16 pm

Simon H said:


I did read you can vnc back into itself as well as remotely but that is a bit messy.

Yes the XBMC Android remote is great, I use it at home to control both an old Xbox 1 hacked with XBMC on it and my laptop connected to my TV that is the main media center. The next Pi I get will be going to replace my laptop which is noisy when playing HD video and frankly a waste sitting behind my TV. Look in other XBMC threads, there is alot of discussion about using all sorts of remote controls on it.

Openelec have already released early XBMC code which some have compiled successfully in another thread, will be having a go myself when I get a spare hour or 2.


OK, great - I'll definitely give it a go.  I saw something about XMBC earlier - I haven't had a chance to take a look yet, it looks promising.

On a side note I've just installed XRDP and I can connect using MS RDP client (mstsc).  I haven't had a chance to connect it to my TV yet to see if it replicates what's being put out the HDMI port but I'll try it out and feed back.

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 8:20 pm

Tass said:


Simon H said:


I did read you can vnc back into itself as well as remotely but that is a bit messy.

Yes the XBMC Android remote is great, I use it at home to control both an old Xbox 1 hacked with XBMC on it and my laptop connected to my TV that is the main media center. The next Pi I get will be going to replace my laptop which is noisy when playing HD video and frankly a waste sitting behind my TV. Look in other XBMC threads, there is alot of discussion about using all sorts of remote controls on it.

Openelec have already released early XBMC code which some have compiled successfully in another thread, will be having a go myself when I get a spare hour or 2.


OK, great - I'll definitely give it a go.  I saw something about XMBC earlier - I haven't had a chance to take a look yet, it looks promising.

On a side note I've just installed XRDP and I can connect using MS RDP client (mstsc).  I haven't had a chance to connect it to my TV yet to see if it replicates what's being put out the HDMI port but I'll try it out and feed back.



Will be interested to hear if that works mirroring the HDMI output, off to take an image of my SD card before I install anything else and break it

User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Tue Apr 24, 2012 8:56 pm

Simon H said:


Will be interested to hear if that works mirroring the HDMI output, off to take an image of my SD card before I install anything else and break it


OK - I've tried it out and it unfortunately has the same effect as VNC - it just creates a new session.  When connecting I initially get this prompt:



I'll play around and see if anything works.

BTW - I don't think it's relevant at all but those of you not yet connecting remotely there's a different background


User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Sun Apr 29, 2012 3:19 pm

FYI - the different desktops are determined by the user initiating the session.  If plugged into a TV, if I run sudo startx I get the LXDE desktop, if I run startx I get the Raspberry Pi desktop.  If I VNC in, if I launch the vnc server via SSH by running sudo vncserver... I get the LXDE desktop, if I run vncserver... I get the Raspberry Pi desktop.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Sun Apr 29, 2012 3:46 pm

OK - so that explains the different backgrounds.  But what explains the "I get a brand new X session" (Unix style VNC) vs. the "I get a mirror of my physical machine at home" (Windows style VNC) ?

I'm guessing (just guessing - no real knowledge - sort of an inference from another ARM box that I have that uses x11vnc) that "regular" VNC (aka, "tight" VNC) does the "Unix style" thing,while "x11vnc" does the "Windows style".  Is that right?

(This implies that "x11vnc" is a different program, not just an alternate name for VNC - somehow, until the last couple of days, I always assumed that it was just an alias)
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

tomtor
Posts: 44
Joined: Sun Apr 08, 2012 2:19 am
Contact: Website

Re: HowTo: Setup a Remote Desktop with VNC server

Sun Apr 29, 2012 4:15 pm

Joe Schmoe said:


OK - so that explains the different backgrounds.  But what explains the "I get a brand new X session" (Unix style VNC) vs. the "I get a mirror of my physical machine at home" (Windows style VNC) ?

I'm guessing (just guessing - no real knowledge - sort of an inference from another ARM box that I have that uses x11vnc) that "regular" VNC (aka, "tight" VNC) does the "Unix style" thing,while "x11vnc" does the "Windows style".  Is that right?

(This implies that "x11vnc" is a different program, not just an alternate name for VNC - somehow, until the last couple of days, I always assumed that it was just an alias)



x11vnc is a VNC server which attaches to a running Xserver (Windows style as you call it). So when you attach to it with a VNC client you see a clone of a running desktop.

vncserver creates a new running XServer instance. You can start several of these so several users can have their own indepent X-session on one physical machine.

User avatar
Tass
Posts: 535
Joined: Sat Jan 21, 2012 11:15 am

Re: HowTo: Setup a Remote Desktop with VNC server

Sun Apr 29, 2012 4:54 pm

OK - I've just installed x11vnc (sudo apt-get install x11vnc), plugged my Pi into my TV, booted it up, ran startx and ran sudo x11vnc and I can connect in with VNC, into the session displayed on the TV.  Thanks!!

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Sun Apr 29, 2012 5:47 pm

OK then!

Problem(s) solved, and everybody is happy!
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

lworbey
Posts: 41
Joined: Tue Dec 20, 2011 12:39 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Sat May 05, 2012 9:28 am

I am following this and have x11vnc server installed but I am unsure how to make it automatically run when the Pi starts up?

I have it auto logging in and startx is run, how do I get x11vnc to then run?

I can run it manually with "x11vnc -usepw"

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: HowTo: Setup a Remote Desktop with VNC server

Sat May 05, 2012 8:07 pm

lworbey said:


I am following this and have x11vnc server installed but I am unsure how to make it automatically run when the Pi starts up?

I have it auto logging in and startx is run, how do I get x11vnc to then run?

I can run it manually with "x11vnc -usepw"


Assuming you're running the Debian Pi release, this article:

http://www.debian-administrati.....rticles/28

will tell you everything you need to know about how to start programs automagically at bootup.  Just substitute "x11vnc" (without the quotes) wherever you see "blah" in the article, and you should be good to go.  BTW, that entire website is a great place to learn all about Debian system administration with plenty of useful examples (hence its name).  I am in no way affiliated with that site, I receive no coinage, folding money, bullion, stock certificates, etc., from them, and just find it a useful place to find answers I've forgotten over the decades.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

ian.macken
Posts: 2
Joined: Sat May 12, 2012 2:22 pm

Re: HowTo: Setup a Remote Desktop with VNC server

Sun May 13, 2012 8:54 am

Hi i am having the same issue, that i want to run the vnc server on boot, but i have tried to follow all the instructions on this forum, but i still am not getting anywhere. from your previous post

#! /bin/sh
# /etc/init.d/x11vnc
#

# Some things that run always
touch /var/lock/x11vnc

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script x11vnc "
echo "Could do more here"
;;
stop)
echo "Stopping script xllvnc"
echo "Could do more here"
;;
*)
echo "Usage: /etc/init.d/x11vnc {start|stop}"
exit 1
;;
esac

exit 0

should the above work?

also does it matter what i call the file as long as i make it an execuatable and update rc.d with it?

thanks in advance

mac

Return to “Networking and servers”