Tuesday 31 May 2011

Access remote systems using ssh and VNC

The default installation of RHEL6 installs openssh-server, thus it is a bit strange that this objective is here at any rate.

SSH

You can check this in your box by issuing the following command:

rpm -qa | grep ssh

which in my box results in this:

openssh-server-5.3p1-20.el6.x86_64
openssh-5.3p1-20.el6.x86_64
openssh-clients-5.3p1-20.el6.x86_64
libssh2-1.2.2-7.el6.x86_64


If openssh-server is not installed, you can install it with the following command:

yum install openssh, openssh-clients, openssh-server, libssh2

Once openssh-server is installed, now we need to make sure that we can use to connect to the server, therefore we need to open the firewall, which can be done with this command:

iptables -I INPUT -p tcp --dport ssh -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

You can save this configuration issuing the following command:

iptables-save > /etc/sysconfig/iptables

VNC

VNC is not installed by default, at least it isn't in my box, and thus needs to be installed:

yum install tigervnc-server

by the way, if you are unsure of what a package is named, you could search yum with


yum whatprovides */vncserver

Make sure that the vnc server is ready to run

chkconfig --list | grep vnc

I get this:

vncserver       0:off   1:off   2:off   3:on    4:off   5:on    6:off

If vncserver is not set to run on runlevel 5, then you should make sure that it does, with the following command:

chkconfig --level 5 vncserver on

Now, you need to add a vnc password to your user, so type and follow the instructions:

vncpasswd

You will need to edit the /etc/sysconfig/vncservers file to add your user, like I've done in my box:

VNCSERVERS="1:auser 2:anotheruser"

VNCSERVERARGS[1]="-geometry 1200x800"

VNCSERVERARGS[2]="-geometry 1024x768"


You can start the server now with: service vncserver start or /etc/init.d/vncserver start, which in my box results in the following output, informing me that there is a Desktop listening for each user.


1:user
New 'RHEL6Blade:1 (user)' desktop is RHEL6Blade:1

Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/RHEL6Blade:1.log



Starting VNC server: 2:anotheruser
New 'RHEL6Blade:2 (anotheruser)' desktop is RHEL6Blade:2

Starting applications specified in /home/anotheruser/.vnc/xstartup

Log file is /home/anotheruser/.vnc/RHEL6Blade:2.log

This means that you will be able to connect with user user on port 5901 and user anotheruser on port 5902, thus you need to open your firewall accordingly.

iptables -I INPUT -p tcp --dport 5901:5902 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

I've had to modify this line in the .vnc/xstartup file:

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm

to this line:

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
exec gnome-session &


However, it seems to work OK now, thus I'm not too sure what is going on here, a bit of reading is called for I guess.

No comments:

Post a Comment