Abstract

This discussion will describe several methods of using one computer from another. Now since this is a Linux group, I will focus of using Linux over a network. I will try to be clear on what techniques are for use behind a firewall and which can be used over the Internet.

Remote control of Linux

Have you ever needed to look up something on another computer in your home and had to go to that computer to view the file? Have you ever wanted to run a program on your laptop but the application was installed on your son’s computer? Have you ever wanted to fix some configuration issue on another computer in your house, but some one else was sitting at that computer?

Well, those are the type of issues we are going to tackle in this talk. But before we start discussing how to control things remotely we should take a minute or two and talk about the windowing system in Linux.

X-Windows

X uses a client-server model: an X server communicates with various client programs. The server accepts requests for graphical output (windows) and sends back user input (from keyboard, mouse, or touchscreen). The server may function as:

  • an application displaying to a window of another display system

  • a system program controlling the video output of a PC

  • a dedicated piece of hardware.

This client-server terminology – the user’s terminal as the “server”, the remote applications as the “clients” – often confuses new X users, because the terms appear reversed. But X takes the perspective of the program, rather than that of the end-user or of the hardware: the local X display provides display services to programs, so it acts as a server; any remote program uses these services, thus it acts as a client.

In this example, the X server takes input from a keyboard and mouse and displays to a screen. A web browser and a terminal emulator run on the user’s workstation, and a system updater runs on a remote server but is controlled from the user’s machine. Note that the remote application runs just as it would locally.

The communication protocol between server and client operates network-transparently: the client and server may run on the same machine or on different ones, possibly with different architectures and operating systems, but they run the same in either case.

X Window System

The X Windows system was designed to allow communications over a network connection. In fact, even when the client and server live on the same computer, they still use a network socket to communicate.

For those of you who would like to know more about X have a look at: Wikibooks Guide to X11

Now that we see how the X windows system works with a computer, we will explore how to use it to communicate between computers.

Remote access from Linux to Linux

Lets first see how you can access one Linux computer from another Linux or Windows computer. Please excuse me if I don’t explain how to do these operations from a Mac, but I don’t own one and am not familiar with their operation. Request: if one of you are familiar with how to perform these operations on a Mac, please send me the information and I will include it.

Telnet

The easiest means of communications between two computers is using the Telnet application.

TELNET (TELetype NETwork) is a network protocol used on the Internet or local area network LAN connections. It was developed in 1969.

By extension, “telnet” also refers to the program which provides the client part of the protocol. TELNET clients have been available on most Unix systems for many years and are available for virtually all platforms. Most network equipment and OSs with a TCP/IP stack support some kind of Telnet service server for their remote configuration (including ones based on Windows NT). However with recent advancements SSH has become more dominant in remote access for Unix-based machines.

TELNET

So if I am sitting at computer A I can use the telnet over the network to connect to computer B. Once I connect using the command telnet <server>. During the connection I will be asked for my login name and password. I can then communicate between the computers using text. Since the computers are connected via Telnet, I do not need the X-windows system to connect. This is especially good when you are using a modem or a slow network connection.

Telnet’s strength is that it does not need windows, or a fast connection. I find it useful when I am at someone’s home and they only have a dialup connection. The down side is that it only handles text.

SSH

Another method of connecting two computers is using the SSH protocol between two computers. This is similiar to using the Telnet application.

In computing, Secure Shell or SSH is a set of standards and an associated network protocol that allows establishing a secure channel between a local and a remote computer. It uses public-key cryptography to authenticate the remote computer and (optionally) to allow the remote computer to authenticate the user. SSH provides confidentiality and integrity of data exchanged between the two computers using encryption and message authentication codes (MACs). SSH is typically used to log into a remote machine and execute commands, but it also supports tunneling, forwarding arbitrary TCP ports and X11 connections; it can transfer files using the associated SFTP or SCP protocols. An SSH server, by default, listens on the standard TCP port 22.

SSH

So if I am sitting at computer A I can use ssh over the network to connect to computer B. Once I connect using the command ssh -l <user> <server>. During the connection I will be asked for my password, since I specified my login name on the command line with the -l option. I communicate between the computers using text. Since the computers are connected via ssh, I do not need the X-windows system to connect. This is especially good when you are using a modem or a slow network connection.

The strength of SSH is that the communication between the two computers is encripted. If you are working over the internet, be sure to use SSH instead of Telnet. But if you are behind a good firewall and trust the other computers on the network, Telnet work fine.

The SSH connection has similiar traits to telnet. I find it useful when I am at someone’s home and they only have a dialup connection. The down side is that it only handles text.

X-windows using Telnet

When I am at home, I typically connect to my Linux server from inside X using the following steps.

  1. xhost + This command allow the Linux server to open a new window on my computer. Warning: many linux distributions disable this use since they consider it a security issue. So how do I tell if this is the case?

    The easiest way I find is to use the command ps -ef | grep -i listen You are looking for the X-server which was started with the option, nolisten. I have found the file “/etc/X11/xinit/xserverrc” usually contains the line: “exec /usr/bin/X11/X -dpi 100 -nolisten tcp”. If you find this setup, change the line to read: “exec /usr/bin/X11/X -dpi 100”.

  2. telnet <server> This will connect your computer to the server using the telnet protocol. You will be asked for your login and password on the server to log in.

  3. <application> & If everything is working correctly, the application will open a window with the application running in it. If the application does not open, here are some suggestions to find out what is wrong.

    • echo $DISPLAY Check that the environment variable DISPLAY has been set correctly. It is normally your computer name followed by :0.0.

    • xclock & This command should open an Xclock on your computer. If this works, you have the connect working, the problem is in your application. Remember, if you have not cleared the “nolisten” option above, the Xclock will not start.

That is all there is to connect one linux box to another linux box using the X-windows system.

X-windows using ssh

Another method of connecting two Linux boxes is to replace Telnet with SSH. We will perform the same operation, but this time I will use SSH.

  1. xhost + This command allow the Linux server to open a new window on my computer. Warning: many linux distributions disable this use since they consider it a security issue. So how do I tell if this is the case?

    The easiest way I find is to use the command ps -ef | grep -i listen You are looking for the X-server which was started with the option, nolisten. I have found the file “/etc/X11/xinit/xserverrc” usually contains the line: “exec /usr/bin/X11/X -dpi 100 -nolisten tcp”. If you find this setup, change the line to read: “exec /usr/bin/X11/X -dpi 100”.

  2. ssh -X -l <user> <server> This will connect your computer to the server using the ssh protocol. You will be asked for your password on the server to log in, unless you are using pass phrases. Also notice that I included the option -X to tell SSH to forward the TCP/IP messages over the link. Without this option, SSH will not pass the windowing information from the Client to the Server.

  3. <application> & If everything is working correctly, the application will open a window with the application running in it. If the application does not open, here are some suggestions to find out what is wrong.

That is all there is to connect one linux box to another linux box using the X-windows system over a secure shell protocol.

Remote access to files using SSH

This is a nod to an article I found in the Linux Journal back in June. SSHFS: Super Easy File Access over SSH Once I tried this, I was addicted. In fact I am using it to write this article.

The way this works is similiar to an NFS mount of a file system over a network.

Network File System (NFS), a protocol originally developed by Sun Microsystems in 1984 and defined in RFCs 1094, 1813, and 3530 (obsoletes 3010) as a distributed file system, allows a user on a client computer to access files over a network as easily as if attached to its local disks. NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call system (ONC RPC).

Network File System

The problem with NFS is that it is very insecure. The problem is that the transfers are not encoded so anyone on the network can look in and possibly tap into it.

So the idea that you can create a file system share which uses SSH to transfer the files, is very useful.

SSHFS (Secure SHell FileSystem) is a file system for Linux capable of operating on files on a remote computer using just a secure shell login on the remote computer. On the local computer where the SSHFS is mounted, the implementation makes use of the FUSE (Filesystem in Userspace) kernel module. The practical effect of this is that the end user can seamlessly interact with remote files being securely served over SSH just as if they were local files on his/her computer.

SSHFS

The setup is best done by a package install program. You need both the sshfs package and the fuse package. The fuse package is a filesystem module for the kernel.

To connect my laptop to the server I just enter the command: sshfs <user>@<server>: <local-directory>. The system will ask you for your server password before making the connection.

The best part is that all your file commands work just as though the files were local. This works well when you want to keep important files on a server where they are backed up, but manipulate them on a laptop.

Remote access from Windows to Linux

Telnet / SSH to Linux

We saw above how we could connect from Linux to Linux using the Telnet or SSH text mode. The same operations can be performed using these tools under Windows.

The Telnet application is normally included with windows, although there is one available in Cygwin, the SSH must be installed. Additionally there are application such as Tera Term Home Page and PuTTY: A Free Telnet/SSH Client.

  1. telnet <server> When issued from a Dos Box it will connect you to the server. You will need to use your login and password on the server. Or you can use the command ssh -l <user> <server> to connect using SSH. Since you specified your login name on the command line, you will only be asked for your password.

That is all there is to it. Even though this gives you only a text connection, it is often sufficient to run applications or read data. Yes, you are reduced to working without fonts or images, but this is a fast and stable environment.

Connecting to Linux using Cygwin X server

Now that we have seen how to connect from Linux to Linux, lets see what we can do about connecting Windows to Linux. For this talk I am going to assume you have Cygwin’s X-server installed on your windows box. If it is not installed, now is a good excuse to install it.

Cygwin/X is a port of the X Window System to the Microsoft Windows family of operating systems. Cygwin/X runs on all recent consumer and business versions of Windows; as of 2003-12-27 those versions are specifically Windows 95, Windows 98, Windows Me, Windows NT 4.0, Windows 2000, Windows XP, and Windows Server 2003.

Cygwin/X consists of an X Server, X libraries, and nearly all of the standard X clients, such as xterm, xhost, xdpyinfo, xclock, and xeyes. Cygwin/X, as the name implies, uses the Cygwin project which provides a UNIX-like API to Xlib and X clients, thereby minimizing the amount of porting required.

Cygwin/X

So lets start by assuming you are sitting at a Window computer which has Cygwin X-server installed. Here is how I would connect.

  1. startxwin.bat is the command you would execute from a Dos Box. I tend to prefer to execute the command from a Dos box so I can see the messages produced, as opposed to using the Run command.

  2. xhost + Once an Xterm has opened on your desktop, you need to stop the system from preventing other computers from opening windows on this X-server.

  3. telnet <server> Connect to the linux server with telnet. Or conversely, you could connect using the command ssh -X -l <user> <server> to open the connection using SSH instead of telnet.

  4. <application> & Start your application on the Linux server and it displays on the windows box.

    OK, lets go through our troubleshooting check list of what to do if the application does not appear.

    • Check if the DISPLAY variable is set. Use the command echo $DISPLAY to check if the variable is set. If not you can use the command export DISPLAY=<server>:0.0 to set it. I find when I use SSH it often does not autoset the DISPLAY variable.

So you are now connected. When you finish with a session, you exit from a Telnet or SSH session using exit.

Remote access from Linux to Windows

Well now that we have connected to Linux from both Linux and Windows. How can we connect from Linux or Windows to a box running Windows.

There are commerical solutions available but given that I am an advocate of Open Source solutions, I will explain some using Open Source or Linux tools.

Running a Windows computer from Linux

What Is TightVNC?

VNC (an abbreviation for Virtual Network Computing) is a great client/server software package allowing remote network access to graphical desktops. With VNC, you can access your machine from everywhere provided that your machine is connected to the Internet. VNC is free (released under the GNU General Public License) and it’s available on most platforms. Original VNC distribution can be obtained at this site.

Here you can find an enhanced version of VNC, called TightVNC, which includes a lot of new features, improvements, optimizations and bugfixes over the original VNC version, see the list of features below. Note that TightVNC is still free, cross-platform and compatible with the standard VNC. Many users agree that TightVNC is the most advanced free remote desktop package. And it’s being actively developed so you can expect that TightVNC will become even better.

TightVNC can be used to perform remote control and administration tasks in Windows, Unix and mixed network environments. It can be very helpful in distance learning and remote customer support

Introduction to TightVNC

To use the TightVNC application you need to install it on both computers. You can download the application from the website TightVNC to install it in Windows.

Before you download the Linux version, check that your package manager does not already have it. Debian does.

So once it is installed on windows, you need to start the server, unless you set it up as a service. Since the setup is relatively easy, just fill in the variables on the startup page. Besure you set the password so you can connect. Lets look at what you need to do to make the connection from linux.

  1. vncconnect <server> This connection tool establishes which VNC server you want to connect to.

  2. xvncviewer Starts the client application. This will ask for the name of the server you are connecting to, and the password. If all goes well you should be viewing the screen now.

Working with the Windows screen from here is pretty straight forward. The biggest limitation of this approach is the speed of your network connection. Because you are using the network, you will sometimes see a delay between your actions and the response on the screen. If you have something happening on the screen be prepared to be disappointed.

One interesting aspect of this is that anyone sitting infront of the server will get to watch waht you are doing. This can be good or bad. When you are using Xwindows the user is not aware of what is going on, since all the display is happening on your computer. But with VNC both displays show the information.

From Linux to Windows using SSH

OK now that we have seen VNC in action, what other methods are available to connect Linux to a Windows box. Well have you thought about SSH?

Yes it is possible to set up a SSH server on Windows which you can connect to using SSH. The beauty of SSH is that it is not tied to any one OS.

The setup is available at How to install a ssh server on a Windows 2000 or XP

The good part of this is that you can connect from either Linux, Windows, or Mac if you are using SSH. This means that you have a secure method of connecting two windows machines over a network.

You even have the other applications supported by Cygwin. The down side is that any application not written for Cygwin will not work over the link. After all the applications must support the X protocol to work.


Written by John F. Moore

Last Revised: Wed Oct 18 11:01:33 EDT 2017

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
HTML5 Powered with CSS3 / Styling, and Semantics