Вопрос

I need to create a way to communicate commands and transfer files from a host server to a development board.

  • The only access to the board is via the host server (wired Ethernet connection).
  • Both the host server and the board are running Linux.
  • I have the ability to change the Linux environment on the board.
  • I DO NOT have the ability to change the host server environment.
  • I DO NOT know which users need to connect to the board.
  • The connection between the host server and the board does not need to be secure.

Right now, I'm using netcat for my needs but have run into reliability issues - Could someone point me to some tools that are better suited to my needs and perhaps higher performance, please?

My current solution:

A script is constantly running on the board:

while [ 1 ] ; do
    # Start a netcat server, awaiting a file.
    nc -l -p 1357 > file.bin

    # Acknowledge receipt of file.
    status=fail
    while [ ${status} -ne 0 ] ; do
        status=$(echo 0 | nc <host_ip> 2468 2>&1)
    done

    # Wait for a command.
    nc -l -p 1357 -e /bin/sh

    # Acknowledge receipt of command.
    status=fail
    while [ ${status} -ne 0 ] ; do
        status=$(echo 0 | nc <host ip> 2468 2>&1)
    done
done

The only way users have access to the board is through a script on the server:

# Send over a file.
cat some_file.bin | /bin/nc -w 10

# Wait for acknowledge.
if [ $( nc -l 2468 ) -ne 0 ] ; then
    exit # Fail
fi

# Send a command.
echo "<some_command>" | nc -w 10 <board ip> 1357

# Wait for acknowledge.
if [ $( nc -l 2468 ) -ne 0 ] ; then
    exit # Fail
fi

The reason I'm using netcat right now is that I don't know of any way to use SSH or SCP without a password given that:

  • I can't generate an SSH key for everyone that needs access to the board, especially since I don't know who will be using it.
  • I can't install sshpass or expect since I don't have control of the server.

Please help, Thanks.

Это было полезно?

Решение

You could use SSH with host-based authentication. Then you would not need those script and simply use SSH and SCP normally, without the need for passwords nor user keys.

With host-based authentication, any user connecting from a predefined set of machines (here it would be the host) is automatically authenticated on the target machine (here the board).

You need to modify the SSH server configuration on the board, and the SSH client configuration on the host (which you can do without the need for a root access).

Here is a tutorial that should get you started.

Note that if encryption is not mandatory and performance is of issue, you can use the same host-based authentication scheme for RSH access.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top