More Tips for Remote Access with Oracle Linux
By Robert Chase on Mar 26, 2014
SSH's primary use is for remote access to hosts. SSH is not only able to provide us a terminal interface to a server, it's also able to provide us a transport for a graphical interface. In order to utilize this functionality, we must have an X server running on our local workstation. On a Linux workstation with a graphical environment, this functionality is built in. On other systems, such as a Windows machine or a Mac, this functionality is not built in. Both XQuartz on the Mac and MobaXTerm are X servers for these platforms. There are also a number of other open source and paid products available for both platforms.
Once you have an acceptable X server installed on your local workstation, you can connect with SSH using the following
ssh
command. The -X
enables X11 forwarding for the connection. Keep in mind that the X11
forwarding is based on the user who originally connected. Logging in
with one user and then using sudo
often will not work, depending on the permissions and ownership needed to complete a task.
[user@laptop ~]$ ssh -X 10.0.0.12Once you authenticate, you drop directly to a standard prompt. If you look closely, though, and examine the environment variables in your terminal, you will find an additional environment variable that has the IP address of your workstation. You can examine your environment variables using the
env
command.
DISPLAY=localhost:10.0Now you can launch an application that has a graphical interface, and the interface will be displayed on your local workstation. The following example will launch
gedit
. The ampersand symbol is useful for forking the process in the background so we can retain the use of our terminal.
[user@remotehost ~]$ gedit &Using X11 connections over SSH can be quite useful for using application installers that are graphical, such as the Oracle Universal Installer for Oracle Database.
The
screen
application is a great compliment to SSH and is quite useful for sharing an SSH session with another user. Because of the way screen
preserves sessions for the user, it is also great for high-latency
network connections that have frequent disconnects and for maintaining
sessions that time out due to security policies. With a regular SSH
connection, if you are disconnected, any processes that were running are
not preserved. Unlike SSH, the screen
application keeps the session alive so it can be connected to again later.
One of the simplest things you can do with
screen
is share a session. You can launch screen
on the terminal you wish to share by issuing the screen
command. Once you do this, a new shell is running inside of screen
. Another user can log in to the same machine and use the command screen -x
to be immediately connected to your shell. They see everything you
type. Even if you disconnect from the machine on either terminal, the
shell will continue to run. This can be quite useful for sharing a
terminal for a demonstration in a remote office or for running a
terminal-based console that is shared between many users.
To see all of the active screen sessions, you can use
screen -list
, which will show active and detached sessions. To connect to a detached session, you can use screen -r
and the pid.session
name listed in the screen -list
output. In the following example, there are five screen sessions running. One of them is detached.
[user@server ~]$ screen -list There are screens on: 24565.pts-1.server (Attached) 24581.pts-2.server (Attached) 24597.pts-3.server (Attached) 24549.pts-0.server (Attached) 24613.pts-4.server (Detached) 5 Sockets in /var/run/screen/S-user.The command
screen -x
can be used to connect to a currently attached session. In the following example, a connection to session 24565 is made:
[user@server ~]$ screen -x 24565If you need access to a full graphical desktop environment remotely, there are a number of packages that can accomplish this. The package
tigervnc-server
is useful for connections to a remote machine providing a full Linux
desktop experience. To set up and install the package, perform the
following steps.
First, run the following command to install the package:
[root@server ~]# yum install tigervnc-serverOnce the package is installed, you need to edit the file
/etc/sysconfig/vncservers
. The VNCSERVERS
line establishes the user accounts that you want to enable the VNC
server for and their display number. In the example below, the user bob
is configured for display 2 and the user sue
is configured for display 3. The VNCSERVERARGS[#]
section allows you to specify options for each display. In this
example, we are specifying a 1280 x 1024 resolution for display 2 and a
1024 x 768 resolution for display 3:
VNCSERVERS="2:bob 3:sue" VNCSERVERARGS[2]="-geometry 1280x1024 " VNCSERVERARGS[3]="-geometry 1024x768"Once the
/etc/sysconfig/vncservers
file has been edited, you need to set passwords for each user account. This is accomplished with the vncpasswd
command. In the following example, the user bob
sets a password using the vncpasswd
command.
[bob@server ~]$ vncpasswd Password: Verify:Once the package is installed, the configuration file is edited, and passwords are set, you are ready to turn on the
vncserver
service. The following two commands start the service and set the service to start automatically at the next boot:
chkconfig vncserver on service vncserver startOnce configured and running, you can connect to your Linux system using a standard VNC client. When connecting, be sure to specify the display and password credentials that are needed in order to connect.
Comments?
I hope these tips and tricks have been useful and that you will take advantage of some of them in the course of your day. We will be publishing more of these tips-and-tricks articles in the future. Feel free to leave a comment for further topics that you would like to see in this series.See Also
Oracle Linux blogAbout the Author
Robert Chase is a member of the Oracle Linux product management team. He has been involved with Linux and open source software since 1996. He has worked with systems as small as embedded devices and with large supercomputer-class hardware.About the Photograph
Photograph taken by Rick Ramsey in Durango in the Fall of 2012Follow OTN Garage on:
Blog | Facebook | Twitter | YouTube
About
Contributors:
Rick Ramsey
Kemer Thomson
and members of the OTN community
Rick Ramsey
Kemer Thomson
and members of the OTN community
Search
Recent Posts
- OTN Virtual Tech Summit July 2015 - Systems Track
- Help Us Find OTN's New Systems Community Manager!
- Tech Article: How to Start Using Docker on Oracle Linux
- A Brief Chat with the Linux Foundation
- Migration and Provisioning Strategies, Plus SWiS for Developers
- Get Your OVM Server On
- The "New to Solaris Development Forum" Has Moved
- 5 Steps for Installing Oracle Database 12c on Oracle Solaris 11
- How to Install and Use Oracle Solaris 11.2 for x86 from an ISO in VirtualBox
- How to Build a Software Defined Network with Oracle Solaris 11
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
freerdp x86_64 1.0.2-2.el6 public_ol6_latest 54 k
Installing for dependencies:
freerdp-libs x86_64 1.0.2-2.el6 public_ol6_latest 207 k
freerdp-plugins x86_64 1.0.2-2.el6 public_ol6_latest 75 k
pcsc-lite-libs x86_64 1.5.2-13.el6_4 public_ol6_latest 27 k
Regards,
Daniel
[root@linux1 Packages]# service freerdp start
freerdp: unrecognized service
[root@linux1 Packages]# rpm -qa | grep freerdp
freerdp-libs-1.0.2-2.el6.x86_64
freerdp-1.0.2-2.el6.x86_64
freerdp-plugins-1.0.2-2.el6.x86_64
Did I miss something?