cnRemoteControl Documentation

Christian Nause, cnremctrl at cntec dot de

v0.1.0, 28.03.2004


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

Many Linux users are lazy. Me too. That's why I decide to program a remote control for my linux server. Maybe it's the same for you: Your linux box works inconspicuous and honest in the corner. You are working about 90 % on your Windows PC. If you just want to make a little job on your Linux PC, you have to start a telnet or a secure shell, login, type your commands, logout and close the shell. That's annoying.

Henceforth I control my Linux PC with a gorgeous colourful program from my Windows PC :) Maybe its useful for someone else.

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, but it's easier to describe cnremctrl as a server. If the user pushes e.g. button no. 3, the client sends a string Button03 via TCP/IP on a reserved port (default 26056/tcp) to the linux server. xinetd is bind on the cnremctrl port and verifies, if the sender IP address is allowed to communicate to 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 doesn't have it yet, look on the Sourceforge project website https://sourceforge.net/projects/cnremctrl. I recommend to install the client binary archive cnremotecontrol-*.zip 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 keep moving?

    Hhm, I have many ideas. Switching the client language is intended. Tabs to control more then one server would be nice. I'm thinking of KDE-, Gnome-, TCL- and DOS-Clients. It depends how many time I can spend. Who wants to help me? 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. You can make all configuration in an option dialogbox windowslike.
    The server is available as binary RPM, as source RPM and as tar archive. You have to prepare only one config file after installation.

    The instruction manual is 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 works probably under each Windows with winsock installed.

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

  • cnRemoteControl\cnRemoteControl.exe (program)
  • cnRemoteControl\cnRemoteControl.ini (configuration)
  • cnRemoteControl\doc\cnRemoteControl.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 into the taskbar. Just drag and drop c:\program files\cnRemoteControl\cnRemoteControl.exe to the taskbar (Fig. 1).

    cnRemoteControl in the taskbar
    Fig. 1: cnRemoteControl in 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 out the IP address or the 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.

    The client expects a server respond less then Timeout milliseconds. Valid values are between 0 and 20000 ms. The connection will be closed and a message box appears if this fails (Fig. 4).

    cnRemoteControl - Timeout failure
    Fig. 4: Timeout failure

    The cnRemoteControl principle was just shown in the introduction: If the user pushes a button, the client doesn't send a linux command to the server but a string ButtonXY. The buttons must labeled under Buttons with appropriate texts so the user knows which command is associated with which button.
    The watchful reader might have seen: The button labels in Fig. 3 have some & signs. These are marks for shortcuts. The letter after & is a shortcut for a button. You can see this due to the button text underscores in main dialog.

    You can activate or deactivate buttons with the Active checkbox.

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

    cnRemoteControl - Security check
    Fig. 5: Security check

    So the client installation has finished and the server installation is waiting.


    2.2 Server

    The 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 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 its time to 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. Attend the exit value of xinetd after restarting. If the conf file is buggy, xinetd might not start properly. If xinetd doesn't run, all xinetd services doesn'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 sources. You can ignore the compiler warning passing arg 3 of `poptGetContext' from incompatible pointer type if it appears. This theme 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 to security. As you know the client sends only strings like ButtonXY to the server. No executable commands are send over TCPI/IP so nobody can infiltrate his own commands.

    Note: My demand on this remote control is that all commands are executable. So cnremctrl runs as root and the admin is responsible to configure cnremctrl proper!

    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