I've created a simple shell script named /usr/sbin/helloworld
#!/bin/bash
echo "Hello World"
mkdir ~/itran
read -p "Say Hello : " hello
echo "$hello"
exit 0
I created /etc/xinetd.d/testservice-map as below
service testservice
{
port = 4079
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/helloworld
server_args = test
}
and added the line below in /etc/services
testservice 4079/tcp
I've assigned one IP to my host and added an IPTABLE rule to redirect the request on port 22 of that IP to port 4079 of localhost
Now when I SSH to that IP using putty from another machine, from the logs (/var/log/messages) I can see that my service is being executed on the host but I can't see the "Hello World" message. The directory "itran" gets created but I can't see the echo message nor can I input any value.
I'm new to this. Kindly let me know if any more information is needed. Any help would be much appreciated.
The problem that you have is that ssh does a lot more than you expect.
What happens is:
With some verbose-options on your ssh-client, you can probably observe this behaviour.
Now, other clients do not have a first protocol handshake. If you have a telnet-client, you will probably get your expected result with
Otherwise, try
nc
.