I think you could do that with netcat (command : nc
)
You could do like the following example (which can be found in netcat manpage !):
$ echo "QUIT" | nc <yourhost> 22
SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1
Protocol mismatch.
$ # prompt returned here
You can specify a connection/idle timeout with -w
flag. (see the manpage).
This example connects to the given port (here 22/SSH), read from it then send the string "QUIT". Note that "QUIT" string is arbitrary, depending on the expected protocol: with the example above it could be any string - the SSH server would terminate the connection.