Skip to content

Tag: rhel

RealVNC on RedHat Enterprise 5

This describes how to use the free versions of RealVNC to connect to your RedHat Enterpirse Linux 5 desktop from your Windows XP machine.  These instructions might work for RHEL4, CentOS, Windows Vista, and other flavors of Linux, but I haven’t tried them.  YMMV.

First download the latest free version for Linux to your RedHat machine from here:

http://www.realvnc.com/cgi-bin/download.cgi

Note:  Since you are on RedHat, make it easy on yourself and grab the RPM version.

Unzip/Untar the file to extract the RPM, then install it:

rpm -i vnc-4.*.*.*.rpm

Next, you will need to edit the script which launches RealVNC or else it will choke on the font paths.  So, as root, edit this file:

/usr/bin/vncserver

You should see a section in that file that looks like this:

# Add font path and color database stuff here, e.g.:
#
# $cmd .= " -fp /usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/";
# $cmd .= " -co /usr/lib/X11/rgb";
#

To jump to it quickly, just search for the word ‘font’ in your editor.

Now, you want to uncomment and edit the two necessary lines so that it looks like this:

# Add font path and color database stuff here, e.g.:
#
$cmd .= " -fp /usr/share/X11/fonts/misc/,/usr/share/X11/fonts/75dpi/";
$cmd .= " -co /usr/share/X11/rgb";
#

Got it? Good.  Save that sucker and close it.

Don’t Run RealVNC As Root.

You need to be logged in as a non-root user when you fire up the VNC server, lest the application bomb out with errors.  So, once you have chosen the user you wish to be,  log in and edit this file:

/home/username/.vnc/xstartup

You will want to change the last line to use your GUI of choice (I prefer Gnome).

Change:

twm &

To:

gnome-session &

Save that sucker.  Got it? Good.

There is one last thing to do before any of this will work, and that is to open the necessary port in your firewall.  On your RedHat box, open the Firewall editor and add port 5901 to the list of allowed ports.

Fire It Up

Logged in as the non-root user you decided to run this as, enter the following at the command line:

#> vncserver :1

The first time you run this, you will be asked to create a password. Choose something you will remember by the time you get to your Windows machine to connect in a few minutes.

You should see a few notes about the server being started and the log file being created.  And with that, the vnc server is ready for connections from your Windows box.

Setting Up Windows

Now, you need to download and install the free RealVNC viewer to connect to your RedHat machine, which again is available here:

http://www.realvnc.com/cgi-bin/download.cgi

When installing, choose the Viewer option, not the Server option.  Once it’s installed, launch the application, and in the Server field, enter the IP or hostname of your RedHat server, followed by :1.  For example:

192.168.1.2:1

Click OK, and you should be asked to enter the password you created a few minutes ago.  Once you do, if all worked as planned, you should be looking at your RedHat desktop on your Windows machine.

Notes

Stopping RealVNC

Sometimes you may need to stop and restart VNC on the RedHat box.  To do this, log in at the command line and enter:

#> vncserver -kill :1

It should say something like “Killing process 5036”, letting you know it has been completed.

Getting A Better Resolution

If your Windows box has a monitor running at a resolution different than that of your Linux box, you may want to change the resolution at which RealVNC runs.  To do this, just add the desired resolution to the startup command like so:

#> vncserver -geometry 1440x900 :1

Setting up Samba Shares on RedHat Enterprise 5

My goal was to set up a network share on a RHEL5 server using Samba, so that our Windows users could access the shared folder from their desktops.  It was difficult to find any information on doing this and nothing else, such as setting up Samba as a domain controller, which I was not interested in.  Sometimes Google gives you more than you want.

If you are running RedHat Enterprise 5, and are interested in setting up Samba shares for Windows users to access, read on.  This may work for other flavors of Linux, and older versions of RHEL, but I can’t vouch for that.

First, make sure the correct Samba packages are installed:

#> rpm -qa |grep samba
samba-client-3.0.28-1.el5_2.1
samba-3.0.28-1.el5_2.1
samba-common-3.0.28-1.el5_2.1
system-config-samba-1.2.39-1.el5

If these are not installed, use yum to grab them and install them.

You may need to open ports in the system firewall so that all of this will work.  The ports that need to be open for Samba to work are:

139 and 445

It’s easiest to do this from your RedHat gui (System > Administration > Security Level and Firewall).

Next, set up the smb service to run at boot time:

#> chkconfig smb on

In RedHat, this will also cause the nmb service to run, which is fine.

Now, start Samba:

#> service smb start

Now, create the directory you want to share.  For this example, I will make it simple:

#> mkdir /dv1

Set permissions accordingly.  In my scenario, I wanted our developers to all be able to access this directory from Windows, and they were all part of the ‘developers’ group on my RedHat server, so I set the permissions like so:

#> chown developers.developers /dv1
#> chmod 755 /dv1

In order to get Samba to share this directory, I had to add the appropriate policies for SELinux, which are mentioned in the smb.conf file.  Assuming you are running SELinux (it’s default with RedHat Enterprise 5), these can be added at the command line.

Since you created a new directory that will be shared with Samba (the ‘dv1’ directory you created earlier), a label must be set for that as well.  Using ‘dv1’ as the directory name, run this:

To set a label use the following:

#>  chcon -t samba_share_t /dv1

Now to configure the Samba configuration file.  Always make a backup of the original before editing any config file!

#> cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

To edit the config file, do this:

#> nano /etc/samba/smb.conf

Under [global] settings, uncomment the necessary lines and make changes so that it looks something like this:

workgroup = YourWindowsWorkgroupName
server string = YourRedhatServerName
netbios name = YourRedhatServerName
hosts allow = 127.0.0.1 192.168.1.

Leave everything else in that section the way it is.

Note:  the 192.168.1.  address needs to be that of your local network.

Then under Standalone Server Options:

    security = user
    passdb backend = tdbsam

I commented out all Printer sharing crap since I didn’t use any of that.

Lastly, under Share Definitions:

[homes]
        comment = Home Directories
        browseable = no
        writeable = yes
;       valid users = %S
;       valid users = MYDOMAIN%S

;[printers]
;       comment = All Printers
;       path = /var/spool/samba
;       browseable = no
;       guest ok = no
;       writeable = no
;       printable = yes

[dv1]
        comment = My dog has fleas
        path = /dv1/
        valid users = user1,user2,user3
        public = no
        writeable = yes
        create mask = 0765

Obviously, swap out user1,user2,user3 with the users who will be accessing this share.  You put the username for the RedHat box you are on, not the Windows username (unless it’s the same).

Save the file and go back to the command line. Test it out by running this:

#> testparm

You shouln’t see any error reported.  If all is good, run this:

#> service smb restart

You will see smb and nmb stop and restart.  There should be no errors or “FAILED” notices.

Assuming your users already have accounts on your RedHat box, you need to add them to Samba like so:

#> smbpasswd -a username
New SMB password:
Retype new SMB password:

I set a temporary password here, then ask them to change it next time they log into the server at the command line by running this:

#> smbpasswd

It will prompt them for their old password (the temporary one you just gave them), and for the new one.

Once all that is done and you have set your own Samba password, you should be able to do this from Windows:

Go to Start and select Run.  Type in the hostname of your RedHat server (which you specified in the smb.conf file) like so:

\YourRedhatServerName

You will be prompted for a username and password, and you should enter the RedHat server login name and the Smaba password that you just created.

If all goes well, a window will appear which shows the dv1 directory.  You can now drag, drop, copy, and paste to and from this folder as if it were on your Windows machine!

Clicky