cnRemoteControl Documentation

Christian Nause, cnremctrl at cntec dot de

v0.1.2, April 7th, 2004           SourceForge.net Logo


cnRemoteControl is a client/server based application to control your Linux PC by a Microsoft Windows program via network.

Many Linux users are lazy. So am I. That's why I decided to program a remote control for my linux server. Maybe it's the same for you: Your linux box works inconspicuously in one corner. You spend about 90 % of your time on your Windows PC. If you just want to carry out a little job on your Linux PC, you have to start a telnet or secure shell, login, type your commands, logout and close the shell. That's annoying.

I now control my Linux PC with a gorgeous colourful program from my Windows PC :) Maybe it's useful for someone else, too.

1. Introduction

2. Installation and Instruction manual


1. Introduction

1.1 How does it work?

It's easy: There is the windows client called cnRemoteControl.exe and the linux server application called cnremctrl. Actually cnremctrl isn't a server, because the TCP wrapper xinetd handles all that network and daemon stuff. I call it a server for simplicity reasons. If the user clicks on client button no. 3, the client sends the string Button03 via TCP/IP to a reserved port (default 26056/tcp) on the linux server. xinetd is bind on the cnremctrl port and verifies, whether the sender IP address is allowed to communicate with the server. If the result is ok, xinetd pipes the string Button03 to cnremctrl. cnremctrl looks for an appropriate command in its config file. If a command no. 3 is defined, it will be executed via a system call. All command output to stdout is piped back to the client which displays it in a log section. Voilà.


1.2 Where can I get it?

If you don't have it yet, look on the Sourceforge project website https://sourceforge.net/projects/cnremctrl. I recommend to install the client binary archive cnremotecontrol-en-*.zip (en = English documentation) and the server RPM cnremctrl-*.i386.rpm. That's the easiest way.

The server RPM was build on RedHat 9. Everyone is welcome to build RPMs or APTs for other distributions. I'm going to publish it here. Just contact me: cnremctrl at cntec dot de.

Note: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You find the license here: http://www.gnu.org/copyleft/gpl.html.


1.3 More information

  • Sourceforge project website
  • Manpage cnremctrl(1) server application
  • German documentation cnRemoteControl
  • xinetd homepage
  • xinetd article LinuxFocus

  • 1.4 Copyright

    This document is Copyright 2004 by Christian Nause. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found here: http://www.gnu.org/copyleft/fdl.html.


    1.5 Disclaimer

    Use the information in this document at your own risk. The author disavows any potential liability for the contents of this document. Use of the concepts, examples, and/or other content of this document is entirely at your own risk. All copyrights are owned by their owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements. You are strongly recommended to take a backup of your system before major installation and backups at regular intervals. Comments and questions are welcome.


    1.6 Contact

    Contact the author at cnremctrl at cntec dot de.


    1.7 How does it go on?

    Well, I have many ideas. Simple switching the client language is planned. Tabs to control more than one server would be nice. I'm thinking of KDE-, Gnome- and TCL-Clients. It depends on how much time I can spend. If you want to help - just contact me.


    2. Installation and Instruction Manual

    Installation is easy. The client is made up of three files, so there is no need for a setup program. All configuration settings are made windowslike in a dialog box. The server is available as binary RPM, source RPM and as tar archive. You have to adjust only one config file after installation.

    The instruction manual is as short as possible: Push a desired button and watch for the log section. That's it.


    2.1 Client

    The client was tested under Windows 98, 2000, NT and XP. It uses standard Windows API calls, so it probably works under each Windows with winsock installed.

    After decompressing the binary archive cnremotecontrol-*.zip you get these files :

  • cnRemoteControl\cnRemoteControl.exe (program)
  • cnRemoteControl\cnRemoteControl.ini (configuration)
  • cnRemoteControl\doc\cnremotecontrol-en.html (this helpfile)
  • cnRemoteControl\doc\cnremctrl-man-en.html (manpage cnremctrl)
  • cnRemoteControl\doc\images (some snapshots)
  • Move the directory cnRemoteControl into a desired directory, e.g. c:\program files. It's a good idea to have a link to cnRemoteControl on the taskbar. Just drag and drop c:\program files\cnRemoteControl\cnRemoteControl.exe onto the taskbar (Fig. 1).

    cnRemoteControl on the taskbar
    Fig. 1: cnRemoteControl on the taskbar

    Fig. 2 shows the started cnRemoteControl with pushed button 3 uptime.

    cnRemoteControl - Main dialog
    Fig.2: Main dialog

    Next you have to prepare the configuration. Open the dialog File - Options (Fig. 3).

    cnRemoteControl - Options
    Fig.3: Options

    Fill in the IP address or hostname of your server under IP-Addr. or Name. cnRemoteControl tries to resolve the IP address if you type in the hostname. If this fails, a message box appears and you have to check the DNS configuration of your Windows PC (file hosts).

    The Port is the cnremctrl server port. You can choose each free port on your system, default value is 26056.

    With Timeout you define the time in which the client expects a server response. The connection will be closed and a message box appears if this fails (Fig. 4). Valid values are between 0 and 20000 ms.

    cnRemoteControl - Timeout failure
    Fig. 4: Timeout failure

    The cnRemoteControl principle was shown in the introduction: If the user clicks on a button, the client doesn't send a linux command to the server but a string ButtonXY. The buttons must be labelled under Buttons with appropriate texts to let the user know which command is associated with which button.
    The watchful reader might have seen: The button labels in Fig. 3 have some & signs. These marks are shortcuts whereas the following letters are the accelerator keys. These shortcuts can be seen in the main dialog as the underscored letters in the button text.

    You can activate or deactivate buttons with the Active checkbox.

    Sec. stands for security check. An OK/Cancel Message box appears (Fig. 5) if you push a button with the checkbox activated. Here you can check execution for critical commands like shutdown.

    cnRemoteControl - Security check
    Fig. 5: Security check

    With this client installation has finished and server installation is next.


    2.2 Server

    Server application was tested under RedHat 7 and 9. I'm confident that cnremctrl works well with each common linux distribution which supports xinetd.

    The application is made of three files:

  • /usr/local/bin/cnremctrl (program)
  • /etc/xinet.d/cnremctrl (configuration)
  • /usr/share/man/man1/cnremctrl.1.gz (english manpage)

  •     or
  • /usr/share/man/de/man1/cnremctrl.1.gz (german manpage)
  • 2.2.1 RPM installation

    rpm checks if xinetd >= 2.3 and popt >= 1.6 are available on your system. If you have to update these packages follow the rpmfind links: xinetd and popt.

    Next install cnremctrl with rpm -ivh cnremctrl-*.i386.rpm. rpm installs the German manpage if you have a German distribution, otherwise the English manpage.

    Now you prepare the config file /etc/xinetd.d/cnremctrl:

    # description: remote control server application
    # Christian Nause, March 25, 2004
    #
    # Please note space workaround!
    # If a command contains one or more spaces, e.g. "ls -al", you have to replace
    # every space with "%20", so the correct commandstring runs "--cmdXY=ls%20-al".
    
    service cnremctrl
    {
            type            = UNLISTED
            port            = 26056
            socket_type     = stream
            protocol        = tcp
            user            = root
            server          = /usr/local/bin/cnremctrl
            server_args     = -s --cmd01=/path/to/command1 --cmd02=/command2%20-para
            wait            = no
            instances       = 1
            per_source      = 1
            only_from       = 1.2.3.4 1.2.3.5 192.168.0.0/24
            log_type        = SYSLOG daemon
            log_on_success  = PID HOST EXIT DURATION
            log_on_failure  = HOST ATTEMPT
    }
    
    Under server_args you edit the commands which cnremctrl must execute. Example: With --cmd01=/path/to/command1 cnremctrl executes /path/to/command1 when Button01 is received.

    Note: The line server_args must not include any linefeeds or backslashes!

    If a command contains one or more spaces, e.g. ls -al, you have to replace every space with %20, so the correct command string runs --cmdXY=ls%20-al. You have to proceed this way because the string has to be interpreted as one program option and xinetd is incapable of handling quotes on server-arguments.

    More cnremctrl command line options for server_args are --syslog (each cnremctrl call will be logged in system log) and --logfile=/logfilepath (each call will be logged in a separate logfile).

    only_from contains one or more IP addresses or a range of IPs in CIDR notation from which the server must accept client requests. Example: With only_from = 1.2.3.4 1.2.3.5 192.168.0.0/24 xinetd accepts only calls from IPs 1.2.3.4, 1.2.3.5 and from subnet 192.168.0.1...192.168.0.254.

    You can leave all the rest of xinetd parameters unchanged. More information for xinetd is available here: xinetd homepage or LinuxFocus article.

    Note: If you change the conf file, you have to reload the configuration! On RedHat type /etc/rc.d/init.d/xinted reload, under SuSE type rcxinetd reload. Watch out for error messages. If the conf file is buggy, xinetd might not start properly. If xinetd doesn't run, all xinetd services don't work!

    If your linux server is blocked with iptables, you have to install two rules to let pass cnremctrl communication. Example:

      iptables -A INPUT  -i eth0 -s 192.168.0.0/24 -p tcp --dport 26056 -j ACCEPT
      iptables -A OUTPUT -o eth0 -d 192.168.0.0/24 -p tcp --sport 26056 -j ACCEPT
    

    The installation of cnRemoteControl has finished at this point and you can test it. The server must execute the appropriate command with each push of a client button without failure. You can consult the logfiles if problems appears. The manpage contains more detailed information.

    2.2.2 Installation from scratch

    cnremctrl needs the library popt. You have to install the lib if it is not on your system.

    After extracting the sources cnremctrl-*.src.rpm or cnremctrl-*.tgz with rpm -ivh cnremctrl-*.src.rpm or tar xzf cnremctrl-*.tgz you should have a source directory cnremctrl-*/. Now you can type the common make and make install to compile and install the application. You can ignore the compiler warning passing arg 3 of `poptGetContext' from incompatible pointer type if it appears. This subject is discussed in some forums.

    You find the application under /usr/local/bin/cnremctrl and the config file under /etc/xinet.d/cnremctrl. Now you have to install the manpage manual: Rename cnremctrl-en.1.gz to cnremctrl.1.gz and move it to the right man1 directory. Use /usr/bin/manpath if you don't know the right place.

    The next necessary steps are described in chapter 2.2.1.


    2.3 Security

    Last but not least some notes about security. As you know the client sends only strings like ButtonXY to the server. No executable commands are send over TCPI/IP so nobody else can infiltrate his or her commands.

    Note: My intention for this remote control was that all commands are executable. So cnremctrl runs as root and the admin is responsible to configure cnremctrl properly!

    It's essential to limit the access to cnremctrl with the parameter only_from. If you configure commands like - Attention, this is a joke! - --cmd01=/bin/rm%20-rf%20/ and set only_from = 0.0.0.0/32 you might accept to send the server into nirvana...

    Please contact me if you find a security bug or if you have other suggestions! You might want to check the project website (https://sourceforge.net/projects/cnremctrl) regularly for updates.


    Top