Setup the Raspberry Pi for remote access with RDP or VNC and a static IP

Either RDP or VNC are easy to install on the Raspberry Pi running Raspbian so that you can connect to your Pi remotely. If you are using Windows computers to connect to the Pi, I’d suggest RDP. It runs faster on the Pi and is easier to setup than VNC (marginally). It also enables you to use the built in Remote Desktop application in Windows, avoiding the need to install additional software. There are good RDP clients available for iOS, Android and OSX so connectivity will never be an issue.

Raspberry Pi

Raspberry Pi

Assuming you have installed Rasbian from the pre-built package on the Raspberry Pi foundation website, you can log straight into your Pi using the following credentials. If you’ve set Raspbian to boot straight into the graphical desktop, you won’t need to log in. Here we will assume you primarily intend to use the Pi remotely, but when you first set it up, you will need to have a monitor attached.

Username: pi
Password: raspberry

Once you’ve connected your Pi, switched it on and logged in with the above credentials, you will probably want to update the software to the latest version. Please note that this may well take 30 minutes or so depending on your internet connection and SD card speed, so you might want to skip if you are in a hurry.

Type the following:

sudo apt-get update

sudo apt-get upgrade

Now that you have the most recent packages installed. You are ready to start installing additional software. Before that however, you will probably want to set the Raspberry Pi to a static IP address. This means that it will always be accessible from the same address on your network. Otherwise it will be difficult to find it as each time it reboots, it may have a new address assigned.

You will need to know your subnet mask and your gateway (router) IP address. This can be easily found in windows using the  following command:

From the start menu (in Windows) run the command prompt (in accessories). This can also be loaded by runnign the command ‘cmd’.

Now enter:


The output should be something like:

IPv4 Address. . . . . . . . . . . :
Subnet Mask . . . . . . . . . . . :
Default Gateway . . . . . . . . . :

Note that the IPv4 address is of your Windows machine. The router is listed here as but it may well be something else.

Now return to your Raspberry Pi and type:

sudo nano /etc/network/interfaces

This will open the nano text editor with super user privileges and allows you to edit the network configuration.

You should see:

iface lo inet loopback
iface eth0 inet dhcp

Change this to:

iface lo inet loopback
iface eth0 inet static

Note that netmask and gateway need to be the same as what you got from ipconfig (above). Address needs to be something different. It will be the fixed ip that you use. Just change the final number in the sequence and put it as something between 10 and 250 (avoiding ones already in use).

Use Ctrl X to exit. Hit Y when prompted to save.

Now restart the network interface to apply changes without a reboot:

sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start

Installing XRDP RDP server on your Raspberry Pi

You are now at the point of installing remote access server software on your Pi. As discussed above, I’d recommend RDP but you can use VNC instead (see below).

To install RDP, type:

sudo apt-get install xrdp

If prompted, enter your password (probably raspberry) and press Y when asked if you want to install.

Restart the Raspberry Pi when installation has finished. You should now be able to remote in using any RDP software such as the Windows Remote Desktop Connection client. The ip address will be the one you set up above. This should work on your local network, but not over the internet unless you have setup your router to divert certain ports to your Raspberry PI ip address, but that is out of the scope of this tutorial as it will depend on your router manufacturer.

When you’ve connected, when prompted, set the module as sesman-Xvnc and use the usual username as password (as above). You should now have a remote desktop running in your client.

Installing a VNC server on your Raspberry Pi

At the command prompt on your Raspberry Pi, enter:

sudo apt-get install tightvncserver

This will install the tightvnc server package. As usual, enter your password and Y if prompted. You will now need to run the vncserver to finish the setup:


You will be asked to set a password. Do not create a view only password (you want to interact). Note that this password is separate from your user account but can be set to the same thing if you want.

Note that when the vncserver runs, it will show what port it is running on. For example:

New ‘X’ desktop is raspberrypi:1

The 1 is needed when connecting. You will need a vnc client installed on your computer. TightVNC offers a free client for Windows.

In the connection dialogue of your VNC client, enter the ip address of your Raspberry Pi followed by ‘:1′. For example 192.168.200:1.

If you have run further instances of the VNC server, you might use 2 or 3 instead of 1. Note you will need your VNC password to connect and not your Raspbian password.

At the moment, unlike XRDP, the VNC server will not be running at reboot by default. You need to manually set this. Without the server running, there will be no way to connect and you don’t want to have to manually type vncserver every time as you may not physically be present at the Raspberry Pi.

At the command prompt (Pi), type:

sudo nano /etc/init.d/tightvncserver

This will create a new initiation file that will be executed when the system is booted.

Enter the following text. Note that it may be easier to do this once the first connection has already been made and then copied and pasted from this site.

# /etc/init.d/tightvncserver
case “$1″ in
su $VNCUSER -c ‘/usr/bin/tightvncserver :1′
echo “Starting TightVNC Server for $VNCUSER ”
pkill Xtightvnc
echo “TightVNC Server stopped”
echo “Usage: /etc/init.d/tightvncserver {start|stop}”
exit 1
exit 0

Use Ctrl X to exit. Hit Y when prompted to save. You will need to give the script executable permissions.

sudo chmod 755 /etc/init.d/tightvncserver

The server can now be started and stopped using:

sudo /etc/init.d/tightvncserver start

sudo /etc/init.d/tightvncserver stop

The following will make it autostart when the Pi is booted.

sudo update-rc.d tightvncserver defaults

I’d go for the RDP option, but if you need to use VNC it works fine too.

7 thoughts on “Setup the Raspberry Pi for remote access with RDP or VNC and a static IP

  1. How fast do you find this vs. local X windows? I find that the local video is a tag slow.

  2. Pingback: .NET i jiné ... : Odkazy z prohlížeče – 26.7. 2013

  3. Thank you for the tutor,

    Xrdp is the easiest way to remote Raspi I guess, than vncserver.
    But, the problem is why if I run Raspi and remote control use RD from Windows will show different what acually run on Raspi via other devices like iPad or Android Phone?

    For example, first I run Deluge on Raspi via RDP Windows. Then, I use iPad to see what Raspi does. But there are different what displayed on RDP Windows and iPad.

    What happen?

    If I try to use vncserver, my Raspi failed to remote SSH. Try to ping IP, still not reachable. Where the wrong side?

  4. @Jae Arif

    XRDP by default creates a new sesstion for each device you connected to the PI, while VNC on the other hand keeps one session for all the devies.
    You can change the XRDP setting, try googling about it.

  5. it didnt work for me
    any ideas

    Font directory ‘/usr/share/fonts/X11/75dpi/’ not found – ignoring
    Font directory ‘/usr/share/fonts/X11/100dpi/’ not found – ignoring
    xrdb: No such file or directory
    xrdb: can’t open file ‘/home/pi/.Xresources’

    pi@raspberrypi ~ $ sudo /etc/init.d/tightvncserver start
    /etc/init.d/tightvncserver: 14: /etc/init.d/tightvncserver: stop}”: not found

    pi@raspberrypi /etc/init.d $ sudo update-rc.d tightvncserver defaults
    update-rc.d: using dependency based boot sequencing
    insserv: warning: script ‘tightvncserver’ missing LSB tags and overrides
    insserv: warning: script ‘mathkernel’ missing LSB tags and overrides

    pi@raspberrypi / $ sudo update-rc.d tightvncserver defaults
    update-rc.d: using dependency based boot sequencing
    insserv: warning: script ‘K01tightvncserver’ missing LSB tags and overrides
    insserv: warning: script ‘tightvncserver’ missing LSB tags and overrides
    insserv: warning: script ‘mathkernel’ missing LSB tags and overrides

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>