January 23, 2018

Remote Desktop for Linux – Install and configure NX server and VNC server

Remote Desktop for Linux

I’ve created this sysadmin user guide, Remote desktop for linux that explaining how you can

remotely connecting to Linux servers with NX or VNC.

 

NX is very good for connecting via VPN to Linux servers. (When VPN is with a slow connection)

 

VNC is very good for connecting internally (LAN) to Linux servers.

System requirements:

Redhat

CentOs

Fedora

Free NX server version – 0.7.3-18

NX Client veriosn – 3.5.0.32-3

VNC server version – 4.1.2-14

VNC Client  version – 5.2.3

Let’s get started…

  • Install and configure NX server
  • Install and configure NX Client
  • Install and configure VNC server
  • Troubleshooting

Install and configure NX server.

NX Server Installation and Configuration.

FreeNX in the EPEL + nux-dextop repositories for CentOS 6

To install  freenx server “NX freenx-server” via RPM command:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm

[root@hostname~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

[root@hostname~]# rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm

After you have done to install the “freenx-server” you need to configure the /etc/nxserver/node.conf.

First backup copy of node.conf file:

[root@hostname~]# cp /etc/nxserver/node.conf /etc/nxserver/node.conf.bk

Edit the node.conf file and change the lines as follows:

[root@hostname~]# vi /etc/nxserver/node.conf

ENABLE_PASSDB_AUTHENTICATION=”1″        #This adds the passdb to the possible authentication methods
#ENABLE_SSH_AUTHENTICATION=”1″            #Disable this row
ENABLE_CLIPBOARD=”both”                            #The copy&paste operations are allowed both between the client and the NX session and vice-versa
NX_LOG_LEVEL=4
NX_LOGFILE=/var/log/nx/nxserver.log

DISPLAY_BASE=10000

Now you need to generate the client id key, go to /usr/libexec/nx/

[root@hostname~]# cd /usr/libexec/nx/

[root@hostname nx]# ./nxkeygen
Unique key generated; your users must install

/var/lib/nxserver/home/.ssh/client.id_dsa.key

on their computers.

For Redhat 6/Centos 6

Start the steps above + Run yum install x2goserver to install all NX libs including nxagent.

This is fix the error you received in NX client “session failed”.

[root@hostname~]# yum install x2goserver

Restart NX server:

[root@hostname~]# /usr/libexec/nx/nxserver –restart

when you have done to install the “freenx-server”, we need to download and install the NX client.

Install and configure NX client.

The NX client that I use is version 3.5.0-9 its old stable version:

Install the NX client on your Windows machine and follows the wizard:

Now you need to create and configure the NX client to connect to the Linux server.

Open the “NX client for Windows” icon on the Desktop and follow the wizard:

After you click finish, the NX client login screen appears, click on configure:

Click on the Key buttonto open the DSA Key client management:

Copy the client-id from the Linux server where you generate the client id key.

location of the client id key:

/var/lib/nxserver/home/.ssh/client.id_dsa.key.

Copy the key including the BEGIN DSA to the END DSA:

[root@hostname~]# cat /var/lib/nxserver/home/.ssh/client.id_dsa.key

—–BEGIN DSA PRIVATE KEY—–
MIIBuwIBAAKBgQCXv9AzQXjxvXWC1qu3CdEqskX9YomTfyG865gb4D02ZwWuRU/9
C3I9/bEWLdaWgJYXIcFJsMCIkmWjjeSZyTmeoypI1iLifTHUxn3b7WNWi8AzKcVF
aBsBGiljsop9NiD1mEpA0G+nHHrhvTXz7pUvYrsrXcdMyM6rxqn77nbbnwIVALCi
xFdHZADw5KAVZI7r6QatEkqLAoGBAI4L1TQGFkq5xQ/nIIciW8setAAIyrcWdK/z
5/ZPeELdq70KDJxoLf81NL/8uIc4PoNyTRJjtT3R4f8Az1TsZWeh2+ReCEJxDWgG
fbk2YhRqoQTtXPFsI4qvzBWct42WonWqyyb1bPBHk+JmXFscJu5yFQ+JUVNsENpY
+Gkz3HqTAoGANlgcCuA4wrC+3Cic9CFkqiwO/Rn1vk8dvGuEQqFJ6f6LVfPfRTfa
QU7TGVLk2CzY4dasrwxJ1f6FsT8DHTNGnxELPKRuLstGrFY/PR7KeafeFZDf+fJ3
mbX5nxrld3wi5titTnX+8s4IKv29HJguPvOK/SI7cjzA+SqNfD7qEo8CFDIm1xRf
8xAPsSKs6yZ6j1FNklfu
—–END DSA PRIVATE KEY—–

Paste the client id key and save:

Click OK

Now you are ready to connect Linux server via the NX client.

Note: To Remote Desktop for Linux, you need a Linux user, if you don’t have Linux user please create one.

Or

You can use the NIS server  to create Linux user.

Install and configure VNC server.

Some of the Linux distribution,  the VNC server are installed by default.

You just need to start the service:

[root@hostname~]# /etc/init.d/vncserver start

Or 

[root@hostname~]# service vncserver start

Install VNC server from YUM command:

[root@hostname~]# yum install tigervnc-server

Or

[root@hostname~]# yum install vnc-server

Restart the VNCSERVER service to start working with VNC:

[root@hostname~]# /etc/init.d/vncserver restart

Or 

[root@hostname~]# service vncserver restart

Now you need to create a VNC user, “su” to Linux user:

[root@hostname~]# su user

[user@hostname~]$ vncpasswd

Password:

Verify:

[user@hostname~]$

Follow this steps to create the VNC user X session:

[user@hostname~]$ vncserver                     #create VNC session with default resolution and X display.

New ‘hostname:3 (user)’ desktop is host:3

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/host:3.log

When you created the VNC session the default X display and the default is TWM or other X display, to fix it you need to change some lines in xstartup file located in /home/user/.vnc/

Kill VNC process:

[user@hostname~]$ vncserver -kill :3              #:3 is the port user its created automatically when you run only “vncserver” command  

Killing Xvnc process ID 12375

[user@hostname~]$

Use GNOME to your X display by changing the line in the xstartup file, go to /home/user/.vnc/xstartup disable TWM & by # and add gnome-session &

[user@hostname~]$ vi /home/user/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
#twm &
gnome-session &

Start VNC session:

[user@hostname~]$ vncserver 

New ‘hostname:3 (user)’ desktop is host:3

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/host:3.log

Download and install a VNC viewer and connecting to a Linux server with IP address or Host Name & port:

When you click connect, password screen appear.

Enter the password of the VNC user and click OK:

You have completed the installation and configuration of the VNC server.

Troubleshooting – Remote Desktop for Linux

To increase the user screen resolution to 1920×1080, first kill the VNC process by “vncserver -kill :3

Follow this command:

[user@hostname~]$ vncserver -kill :3

Killing Xvnc process ID 12375

[user@hostname~]$

[user@hostname~]$ vncserver :3 -geometry 1920×1080 -depth 24 

New ‘hostname:3 (user)’ desktop is host:3

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/host:3.log

#you can remove the :3 to automatically get VNC session port. 

To lock VNC session port to VNC user, go to /etc/sysconfig/vncserver and add the VNC user to VNCSERVERS=

And the user resolution to VNCSERVERARGS=

[user@hostname~]$ vi /etc/sysconfig/vncserver

# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own). You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see this URL:
# http://kbase.redhat.com/faq/docs/DOC-7028

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the “-via” option in the
# `man vncviewer’ manual page.

VNCSERVERS=”3:user”
VNCSERVERARGS[3]=”-geometry 1920×1080″

To add more than one user to the /etc/sysconfig/vncserver file:

[user@hostname~]$ vi /etc/sysconfig/vncserver

# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own). You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see this URL:
# http://kbase.redhat.com/faq/docs/DOC-7028

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the “-via” option in the
# `man vncviewer’ manual page.

VNCSERVERS=”3:user 4:userA 5:userB 6:userC”
VNCSERVERARGS[3]=”-geometry 1920×1080″
VNCSERVERARGS[4]=”-geometry 1920×1080″
VNCSERVERARGS[5]=”-geometry 1920×1080″
VNCSERVERARGS[6]=”-geometry 1920×1080″

About The Author

IT professional for 17 years in complex networking Linux and Windows environments.

Related posts

1 Comment

Leave a Reply

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


Fatal error: Call to undefined function pp_popup() in /home/shira13/public_html/wp-content/themes/multinews/footer.php on line 73