Force SSH server to always and only tunnel to telnet server

0

I have this structure:

client ---> server(debian) ----> target

target is a telnet server.

I'm able to SSH from client to server and then execute telnet to reach target.

How can I configure server (not client), to, as soon the SSH connection is made, open telnet and leave as soon it closes?

From client I know I can use ssh user@server_ip "telnet target_ip", but I don't have control over client and I don't want eventual clients having any other access to server besides telneting target.

Is this possible?

Gustavo Vargas

Posted 2018-09-01T03:00:26.703

Reputation: 103

Answers

1

Sure, you may change shell for the user from bash/tcsh/etc to some script which does the telnet.

go to /etc/passwd, find the user and edit the shell at the end of the line to /usr/bin/yourshell, which can be something like this:

#!/bin/bash
telnet target_ip

then do 'chmod +x /usr/bin/yourshell' and you are good to go.

The user will automatically log off from ssh, as soon as he exits telnet session.

MTG

Posted 2018-09-01T03:00:26.703

Reputation: 184